Last active
October 12, 2017 12:19
-
-
Save bentaylorwork/d30d2eb3b719cd080a9a3a1cc1ded083 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$adUsers = Get-AdUser -Filter * -Properties name, department | |
$uniqueDepartments = $adUsers | Where-Object { $_.department -ne $null } | Select-Object -ExpandProperty department -Unique | |
foreach ($uniqueDepartment in $uniqueDepartments) { | |
$variableSplat = @{ | |
'Name' = ($uniqueDepartment -replace ' ', '') | |
'Value' = $adUsers | Where-Object { $_.department -eq $uniqueDepartment } | |
} | |
Set-Variable @variableSplat | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment