I have the following code which works but I would like to write to the output the users DN but I cannot work out how to access the imbedded hash table. Can any help me with this simply fix :)
$usersou = "ou=users,ou=company,dc=green,dc=sophos"
$disabled_users = Search-ADAccount -AccountDisabled -UsersOnly -searchbase $usersou | select samaccountname,name,DistinguishedName|group-object -property samaccountname -ashashtable
foreach($user in $disabled_users.keys)
{
write-output "Move user object $user to disabled OU"
move-ADObject $user -targetpath $disabledou -whatif
}
Mike