This file contains hidden or 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
#intent is to eventually update DPAT to accept these other fields | |
#$properties = @('UserPrincipalName';'Enabled';'PasswordLastSet';'PasswordExpired';'PasswordNeverExpires';'whenCreated';'whenChanged') | |
$properties = @('UserPrincipalName') | |
foreach($group in (get-adgroup -filter *)) { | |
$UPNs = @() | |
$UPNs = Get-ADGroupMember -Recursive $group.samaccountname -ea SilentlyContinue | get-aduser -properties $properties -ea silentlycontinue | Select-Object -ExpandProperty $properties -ea silentlycontinue | |
if($UPNs.Count -ge 1){ | |
$members = @() | |
foreach($UPN in $UPNs){ | |
$members += ("{0}\{1}" -f $UPN.split("@")[1], $UPN.split("@")[0]) |