Powershell: Difference between revisions

From Piszczynski
piszczynski>Aleks
(Created page with " == Handy Powershell == Export details of users in a specific OU: $OUpath = 'OU=CKH Leavers & Disabled Accounts,OU=CKH Users,DC=ckh,DC=local' $ExportPath = 'c:\users\alek...")
 
piszczynski>Aleks
No edit summary
Line 6: Line 6:




$OUpath = 'OU=CKH Leavers & Disabled Accounts,OU=CKH Users,DC=ckh,DC=local'
$OUpath = '<place OU path here distinguished name of ou in attribute editor>'


$ExportPath = 'c:\users\alekscms\disabledaccounts.csv'
$ExportPath = '<place where to put output>'


Get-ADUser -Filter * -SearchBase $OUpath | Select-object DistinguishedName,Name,UserPrincipalName,sAMAccountName | Export-Csv -NoType $ExportPath
Get-ADUser -Filter * -SearchBase $OUpath | Select-object DistinguishedName,Name,UserPrincipalName,sAMAccountName | Export-Csv -NoType $ExportPath

Revision as of 10:58, 20 May 2019

Handy Powershell

Export details of users in a specific OU:


$OUpath = '<place OU path here distinguished name of ou in attribute editor>'

$ExportPath = '<place where to put output>'

Get-ADUser -Filter * -SearchBase $OUpath | Select-object DistinguishedName,Name,UserPrincipalName,sAMAccountName | Export-Csv -NoType $ExportPath