Thursday 7 June 2012

Active Directory Quest PowerShell command line....


Below are the few single line Quest PowerShell command s which will help you for routine Active Directory Task.

 Note: This should run on Active Directory Quest PowerShell Command Prompt



Move the Disable users or any user to different OU:


Get-Content "C:\Powershell\DisableAccounts\Duser.txt" | Move-QADObject –NewParentContainer  "OU=Disabled Accounts,DC=lab,DC=com"



Search the Disable users in Entire AD to move to Disbaled OU or Where you want:

Get-QADuser -SizeLimit 0 -ldap "(userAccountControl:1.2.840.113556.1.4.803:=2)" | Move-QADObject -NewParentContainer "OU=Disabled Computers,DC=lab01,DC=com"


To Create Bulk AD account with out Mailbox Users:

Import-CSV C:\NewUser1.csv | ForEach-Object -Process {New-QADUser -Name $_.UserName -FirstName $_.FirstName -LastName $_.LastName-SamAccountName $_.sAMAccountName -UserPrincipalName $_.UPN -ou $_.OU -UserPassword $_.Password}


CSV Format: 
SamAccountName,UPN,OU,Password
Test.Cloud,Test.Cloud@lab.com,"OU=Users,DC=lab,DC=com",Passw0rd12




OU
Password


TO Get AD USER DETAILS:




For whole Domain:

QADUser -SearchRoot "lab.com/" -IncludeAllProperties -sizelimit 0 | select name,LastLogonTimestamp,mail,PasswordNeverExpires,accountExpires,createTimeStamp,PasswordLastSet,userAccountControl | Export-Csv d:\Reports\result.csv

For any OU:
QADUser -SearchRoot "lab.com/hult" -IncludeAllProperties -sizelimit 0 | select name,LastLogonTimestamp,mail,PasswordNeverExpires,accountExpires,createTimeStamp,PasswordLastSet,userAccountControl | Export-Csv d:\Reports\result.csv



For any set of users:

Get-Content "c:\userlist.txt" | Get-QADUser -IncludeAllProperties -sizelimit 0 | select name,LastLogonTimestamp,mail,PasswordNeverExpires,accountExpires,createTimeStamp,PasswordLastSet,userAccountControl | Export-Csv d:\Reports\result.csv

No comments:

Post a Comment