How to add Active Directory powershell module

I’m going to show the steps how to add the AD module in your machine and in the server if you need to get information like run Get-ADPrincipalGroupMembership to know what groups a specific user belongs.

To add this module in your local machine is quite easy. Install the Remote Server Administration Tools for Windows 10 package

But, to install it in a Windows Server for example you need to add this feature following the steps .

  1. Open Server Manager Dashboard
  2. Click Manage -> Add Roles and Features Wizard
  3. Click next until to show the picture below in the item features

After install it (no restart needed) you can run import-module ActiveDirectory and run something like this:

Get-ADPrincipalGroupMembership -Identity 'user_name' | Select-Object name

$groups = Get-ADGroup -Filter {name -like 'user_group'} -Properties * | Select -property name

foreach($group in $groups) {
    if($ -ceq 'Group trying to find') {
        Get-ADGroupMember -Identity $ | Where-Object objectClass -Like 'group' | Select-Object name

Common Git situations and how to solve it

Work with Git can be easy, but sometimes we need to know more than just pull, add, commit and push.

So, below you are going to find examples how to solve the most common scenarios you could face working with Git.

Combine with the previous commit

git commit --amend

Committed all those changes to the master branch by mistake

git branch New-branch
git reset HEAD~ --hard
git checkout New-branch

Made a spelling mistake in my branch name

git branch -m New-brunch New-branch

Clean up local commits before pushing

git rebase -i

Reverting pushed commits

git revert HEAD

Edit a commit message

git commit --amend -m “new message”

Remove a file from git without removing it from your file system

git reset filename

Undo local commits

git reset HEAD

Discard local file modifications

git checkout -- something

Rollback to a specific point

git reflog 
git reset HEAD@{XX} 
-- git add or checkout

Checking the differences between remote and local repository

git diff origin/master master

Useful transactional replication stored procedure

The scenario is when your publication settings has the option
immediate_sync configured as false (means if you run the Snapshot Agent, the snapshot files will be created for the new articles only and also a new subscriber to the existing publication, the snapshot files only get created for the new subscription)

This option immediate_sync will prevent to generate all snapshot files again when add a new article in the replication, but it still need schema lock to check all articles modification.

If you have a large number of articles and a bunch of subscribers, you might face the situation you have to add a new article in your transactional replication and after run the snapshot the article is not propagating to the subscribers.

First, check your publication settings.

exec sp_helppublication 'PublicationName'

If you are using the settings immediate_sync and allow_anonymous false you can run the procedure below to solve the issue that your new article didn’t propagate to your subscribers.

exec sp_refreshsubscriptions 'PublicationName'