Feel free to call me stupid but for some reason my brain is not figuring this out today. The code below searches Active Directory for all enabled users and then selects the Name, username, email, Pager, Office, and Title. It will then write that information to the console. For some reason the Pager, Office, and Title properties are blank. Can anyone tell me what super obvious thing I am missing here?
Import-Module activedirectory
$Users = Get-ADUser -Filter 'enabled -eq $true' | Select-Object -Property Name,samaccountname,UserPrincipalName,Pager,Office,Title
forEach ($person in $Users)
{
Write-Host $person
}
pause
CodePudding user response:
You need to first specify which properties you want to return with Get-ADUser
These properties are included as a default set, and don't need to be explicitly specified
- DistinguishedName
- Enabled
- GivenName
- Name
- ObjectClass
- ObjectGUID
- SamAccountName
- SID
- Surname
- UserPrincipalName
Example
Get-ADUser -Properties Name,Pager,Office,Title | Select Name,Title
Example to return all properties
Get-ADUser -Properties *