This page will give you some very usefull Windows 2008 R2 Powershell cmdlets that you can use to make your Windows administration easier. I will continue to add more cmdlets as I come across them. Anything in Italics represents an input variable.
Modules
Get-Module -ListAvailable (Lists available Modules that can be imported)

Get-Command -Module ModuleName (For example Get-Command -Module ActiveDirectory or Get-Command -Module ServerManager)
Get-Command –Module ModuleName –verb Set (Lists all the Set commands available in the module)
Get-Command –Module ModuleName –noun ADgroup (Lists all the commands containing ADgroup in the module)
Get-Help cmdlet -Full | more (For example Get-Help Get-ADGroup -Full. You can also use this command without the Full to give a shorter description)
Get-PSProvider (Shows a list of mapped variables, For example I can browse ActiveDirectory by firstly changing to cd AD: and then using familiar commands such as dir or cd. I can also browse the directory structure by typing in cd “CN=Users,DC=windowslab,DC=Local”, now if I type dir I can see a list of users or objects in the folder or OU)

Active Directory Users
Get-ADUser UserName (Lists information about a specific username)
Get-ADUser -Filter {Name -like “*SearchVariables*”} For Example Get-ADUser -Filter {Name -like “*minis*”} to search for all users containing the word minis i.e. Administrator
New-ADUser –Name “FirstName LastName” –SamAccountName “firstname.lastname” –Description “Description” –Department “Department” –Office “Office Location” –Path “cn=users,dc=domain,dc=domain” –Enabled $true (For example if we were to create one of the users via this method instead of the import csv method below we would enter the following command: New-ADUser –Name “Ben Jones” –SamAccountName “ben.jones” –Description “Managing Directory” –Department “Sales” –Office “Sydney” –Path “ou=users,ou=sydney,dc=windowslab,dc=local” –Enabled $true)
Import-CSV C:users.csv | New-ADUser (The Import-CSV cmdlet will import a list of users from a CSV file created in excel. Below is a sample of one I have created. You can create more columns using the same Active Directory User Account settings.)

Once the file has been imported you can see the list of users have been created in the Active Directory OU that I specified in the CSV file.

Set-ADUser ADUser –Variable (This command will set the user fields for the specified user account. For example if I want to specify or change the Office location field for a specific user I would type: Set-ADUser ben.jones -Office Brisbane. This command can also be used with the Filter command for mass additions or changes.)
Active Directory Groups
Get-ADGroup GroupName (Lists information about a specific Group. If the Group contains spaces don’t forget to use “”)
Get-ADGroup -Filter {Name -like “*SearchVariables*”} For Example Get-ADGroup -Filter {Name -like “*mins*”} to search for all Groups containing the word mins i.e. Domain Admins, etc
New-ADGroup -name GroupName -GroupScope Global|Universal -Description “Description” -DisplayName DisplayName -SamAccountName AccountName (For example to create a Global Group call TestGroup I would use the following syntax
New-ADGroup -name TestGroup -GroupScope Global -Description “New Group Test” -DisplayName TestGroup -SamAccountName TestGroup
Remove-ADGroup GroupName (Removes/Deletes an ADGroup. You will be asked if you are sure you want to perform this action. You can also use a filter similar to the Get-ADGroup command above)
Set-ADGroup GroupName –Variable (This command will set the definable fields for the specified Group account. For example if I want to specify or change the Description field for a specific group I would type: Set-ADGroup TestGroup -Description “Demo Group”. This command can also be used with the Filter command for mass additions or changes.)
Disclaimer:
All the tutorials included on this site are performed in a lab environment to simulate a real world production scenario. As everything is done to provide the most accurate steps to date, we take no responsibility if you implement any of these steps in a production environment.
Be the first to comment