namerg
asked on
How to export AD Users into a CSV that does not have an employee number
How to export AD Users into a CSV that does not have an employee number?
I do have the following code but the csv comes weird, I would like to have the samaccount, name, lastname etc,etc, Thanks for your help
I do have the following code but the csv comes weird, I would like to have the samaccount, name, lastname etc,etc, Thanks for your help
$Ad = Get-ADUser -SearchBase "OU=OUi,DC=company,DC=com" -Filter * -Properties employeeNumber | ? {(-not($_.employeenumber))}
$Ad | Sort-Object -Property sn, givenName | Select * | Export-Csv c:\scripts\ceridian\NoClockNumber_2013_02_12.csv -NoTypeInformation
ASKER
I am looking for a Powershell code.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Hi this is the code that i figured out what i enter i get. Look if it helps you out in any of the cases...
Here it is in case it might be useful to somebody else.
$alist = "Name`tAccountName`tDescri ption`tEma ilAddress` tLastLogon Date`tMana ger`tTitle `tDepartme nt`tCompan y`twhenCre ated`tAcct Enabled`tG roups`n"
$userlist = Get-ADUser -Filter * -Properties * | Select-Object -Property Name,SamAccountName,Descri ption,Emai lAddress,L astLogonDa te,Manager ,Title,Dep artment,Co mpany,when Created,En abled,Memb erOf | Sort-Object -Property Name
$userlist | ForEach-Object {
$grps = $_.MemberOf | Get-ADGroup | ForEach-Object {$_.Name} | Sort-Object
$arec = $_.Name,$_.SamAccountName, $_.Descrip tion,$_.Em ailAddress ,$_LastLog onDate,$_. Manager,$_ .Title,$_. Department ,$_.Compan y,$_.whenC reated,$_. Enabled
$aline = ($arec -join "`t") + "`t" + ($grps -join "`t") + "`n"
$alist += $aline
}
$alist | Out-File D:\Temp\ADUsers.csv
Hope it helps you.
Thanks.
Here it is in case it might be useful to somebody else.
$alist = "Name`tAccountName`tDescri
$userlist = Get-ADUser -Filter * -Properties * | Select-Object -Property Name,SamAccountName,Descri
$userlist | ForEach-Object {
$grps = $_.MemberOf | Get-ADGroup | ForEach-Object {$_.Name} | Sort-Object
$arec = $_.Name,$_.SamAccountName,
$aline = ($arec -join "`t") + "`t" + ($grps -join "`t") + "`n"
$alist += $aline
}
$alist | Out-File D:\Temp\ADUsers.csv
Hope it helps you.
Thanks.
ASKER
@Subsun: Almost 100%
@jeorge, got an error.
Subsun, namaste.
Why do I get the following extra columns ?
I did try the 2nd option.
Thanks for your help,
G
@jeorge, got an error.
Subsun, namaste.
Why do I get the following extra columns ?
DistinguishedName EmployeeNumber Enabled GivenName Name ObjectClass ObjectGUID SamAccountName SID sn Surname UserPrincipalName PropertyNames PropertyCount
I just need EmployeeNumber, GivenName, Name, SamAccountName, Surname and UserPincipalName or EmailI did try the 2nd option.
Thanks for your help,
G
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
You da man :) Thank you very much.
Run the Search "User with specified employee ID "
and select option "No Value" and select additional attributes
AD Info - Active Directory Reporting
www.cjwdev.co.uk/Software/ADReportingTool/Info.html