A quick intro the Management Shell for AD from Quest Software. You might find it useful if you want to extend AD PowerPack or use AD cmdlets to manage your AD.
1. Quick facts and links You candownload free binaries and user documentation from here: http://www.quest.com/2_0/registration.aspx?requestdefid=13255 Buildshistory for the latest build available here: http://powergui.org/entry.jspa?externalID=762&categoryID=21 ADPowerPack for PowerGUI is available here: http://powergui.org/entry.jspa?externalID=763&categoryID=21 To startthe shell, use the ActiveRoles Management Shell for Active Directory shortcut,located at the Start | Quest Software | ActiveRoles Server start menu group. (If you wantusing AD management cmdlets in default PowerShell window, you have to add ADManagementsnap-in with the following cmdlet: add-pssnapin Quest.ActiveRoles.ADManagement.) All AD managementcmdlets are started with "QAD" prefix, for example Get-QADUser or Add-QADGroupMember. Any cmdletreturns an instance, representing an object in AD. Thus, you can pipe result ofone cmdlet (Get-QADUser) to another (Set-QADUser). 2. Enumerating users, groups and other objects List allusers in my domain: PS C:\> Get-QADUser Name Type DN ---- ---- -- Administrator user CN=Administrator,CN=Users,DC=plab,DC=msk,DC=qsft Guest user CN=Guest,CN=Users,DC=plab,DC=msk,DC=qsft SUPPORT_388945a0 user CN=SUPPORT_388945a0,CN=Users,DC=plab,DC=msk,DC=qsft IUSR_MSK-KRF5PZOQ4 user CN=IUSR_MSK-KRF5PZOQ4,CN=Users,DC=plab,DC=msk,DC=qsft IWAM_MSK-KRF5PZOQ4 user CN=IWAM_MSK-KRF5PZOQ4,CN=Users,DC=plab,DC=msk,DC=qsft ASPNET user CN=ASPNET,CN=Users,DC=plab,DC=msk,DC=qsft krbtgt user CN=krbtgt,CN=Users,DC=plab,DC=msk,DC=qsft John Lennon user CN=JohnLennon,OU=Demo,DC=plab,DC=msk,DC=qsft Paul McCartney user CN=PaulMcCartney,OU=Demo,DC=plab,DC=msk,DC=qsft List allusers in Demo OU: PS C:\> Get-QADUser -ou plab.msk.qsft/Demo Name Type DN ---- ---- -- John Lennon user CN=JohnLennon,OU=Demo,DC=plab,DC=msk,DC=qsft Paul McCartney user CN=PaulMcCartney,OU=Demo,DC=plab,DC=msk,DC=qsft Get help onGet-QADUser parameters: PS C:\> Get-Help Get-QADUser -Detailed Get oneuser - John Lennon: PS C:\> Get-QADUser 'john lennon' Name Type DN ---- ---- -- John Lennon user CN=JohnLennon,OU=Demo,DC=plab,DC=msk,DC=qsft List first-levelorganizational units in your domain: PS C:\> Get-QADObject -SearchRootplab.msk.qsft/ -Type organizationalUnit -SearchScope OneLevel Name Type DN ---- ---- -- Domain Controllers organizationalUnit OU=DomainControllers,DC=plab,DC=msk,DC=qsft Dev organizationalUnit OU=Dev,DC=plab,DC=msk,DC=qsft Microsoft Excha... organizationalUnitOU=Microsoft Exchange Security Groups,DC=plab,DC=msk,DC=qsft Demo organizationalUnitOU=Demo,DC=plab,DC=msk,DC=qsft ExchDemo organizationalUnit OU=ExchDemo,DC=plab,DC=msk,DC=qsft prod organizationalUnitOU=prod,DC=plab,DC=msk,DC=qsft List allusers in my domain, display name and city: PS C:\> Get-QADUser | Format-Table name,city Name City ---- ---- Administrator Guest SUPPORT_388945a0 IUSR_MSK-KRF5PZOQ4 IWAM_MSK-KRF5PZOQ4 ASPNET krbtgt John Lennon ny Paul McCartney ny Find all usersin my domain that has City attribute starts with 'ny' PS C:\> Get-QADUser -city 'ny*' Name Type DN ---- ---- -- John Lennon user CN=JohnLennon,OU=Demo,DC=plab,DC=msk,DC=qsft Paul McCartney user CN=PaulMcCartney,OU=Demo,DC=plab,DC=msk,DC=qsft For JohnLennon display name, description, city, department and title: PS C:\> Get-QADUser 'john lennon' |Format-Table Name,Description,City,Department Name Description City Department ---- ----------- ---- ---------- John Lennon abc ny 3. Updating user properties Set descriptionof the John Lennon's user account: PS C:\> Set-QADUser 'john lennon'-Description 'The Beatles band' Name Type DN ---- ---- -- John Lennon user CN=JohnLennon,OU=Demo,DC=plab,DC=msk,DC=qsft PS C:\> Get-QADUser 'john lennon' |Format-Table Name,Description,City,Department Name Description City Department ---- ----------- ---- ---------- John Lennon The Beatles band ny Set city toLiverpool to all user accounts in the Demo OU: PS C:\> Get-QADUser -ou plab.msk.qsft/demo |Set-QADUser -City Liverpool | Format-Table name,city Name City ---- ---- John Lennon Liverpool Paul McCartney Liverpool 4. User creation Create useraccount for George Harrison and Ringo Starr: PS C:\> New-QADUser -ou plab.msk.qsft/demo-name 'Ringo Starr' -LogonName 'RStarr' -City Liverpool -Description 'The Beatlesband' Name Type DN ---- ---- -- Ringo Starr user CN=RingoStarr,OU=Demo,DC=plab,DC=msk,DC=qsft PS C:\> New-QADUser -ou plab.msk.qsft/demo-name 'George Harrison' -LogonName 'GHarrison' -City Liverpool -Description 'TheBeatles band' Name Type DN ---- ---- -- George Harrison user CN=GeorgeHarrison,OU=Demo,DC=plab,DC=msk,DC=qsft 5. Group operations (The outputis omitted when it is not important for the demonstrated scenario) Create anew group for The Beatles band: New-QADGroup -ou plab.msk.qsft/demo -name 'TheBeatles' -GroupType Security -GroupScope DomainLocal Add allusers with description starts with 'The Beatles' to The Beatles group: Get-QADUser -description 'The Beatles*' |Add-QADGroupMember 'The Beatles' List groupmembers, display name and description: PS C:\> Get-QADGroupMember 'the beatles' |Format-Table name,description Name Description ---- ----------- John Lennon The Beatles band Paul McCartney The Beatles band Ringo Starr The Beatles band George Harrison The Beatlesband 6. Bulk creation Export useraccounts to a CSV file: Get-QADUser -ou plab.msk.qsft/demo | export-csvTheBeatles.csv Delete allusers: (Will beprovided in next build. For now, please use Active Directory Users andComputers snap-in). Import useraccounts from a CSV file: PS C:\> Import-Csv TheBeatles.csv |ForEach-Object {New-QADUser -ou plab.msk.qsft/demo -name $_.Name -Description$_.Description -City $_.City} Name Type DN ---- ---- -- John Lennon user CN=JohnLennon,OU=Demo,DC=plab,DC=msk,DC=qsft Paul McCartney user CN=PaulMcCartney,OU=Demo,DC=plab,DC=msk,DC=qsft Ringo Starr user CN=Ringo Starr,OU=Demo,DC=plab,DC=msk,DC=qsft George Harrison user CN=GeorgeHarrison,OU=Demo,DC=plab,DC=msk,DC=qsft Import useraccounts from CSV file and instantly add them to The Beatles group: (You haveto delete users created on previous step before running import once again): Import-Csv TheBeatles.csv | ForEach-Object {New-QADUser-ou plab.msk.qsft/demo -name $_.Name -Description $_.Description -City $_.City| Add-QADGroupMember 'The Beatles'} Message was edited by: Andrei Polevoi
|