Import-Module ActiveDirectory
$path = Split-Path -parent "C:\Users\[user]\Downloads\*.*"
$LogDate = get-date -f yyyyMMddhhmm
$csvfile = $path + "\ALLADUsers_$logDate.csv"
$LogDate = get-date -f yyyyMMddhhmm
$csvfile = $path + "\ALLADUsers_$logDate.csv"
Get-ADUser -Filter "Enabled -eq 'TRUE' -and employeeType -eq 'Employee'" -Properties displayname, employeeType, enabled, givenname, sn, manager, mail, streetaddress, city, st, postalcode, co, telephonenumber, mobile, ipphone, homephone, extensionattribute2, extensionattribute3, extensionattribute4,
company, department, extensionattribute1, title, physicaldeliveryofficename | Select-Object displayname, employeeType, enabled, givenname, sn, mail, streetaddress, city, st, postalcode, co, telephonenumber, mobile, ipphone, homephone, extensionattribute2, extensionattribute3, extensionattribute4, company, department, extensionattribute1, title, physicaldeliveryofficename, @{Label = "Manager";Expression = {%{(Get-AdUser $_.Manager -Properties DisplayName).DisplayName}}} | export-csv $csvfile -NoTypeInformation
Sources
- Get-ADUser (ActiveDirectory) | Microsoft Learn
- Active Directory: Get-ADUser Default and Extended Properties - TechNet Articles - United States (English) - TechNet Wiki (microsoft.com)
- Get AdUser All Properties in PowerShell - ShellGeek
- Where-Object (Microsoft.PowerShell.Core) - PowerShell | Microsoft Learn
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.