Writing a term script and need to find all OU's with the sub folder of Terminations. The following script below works, but will only return the OU when the complete path is defined. I want to do a wild card search find all OU's with terminations.
#Get-ADOrganizationalUnit -filter {(name -like "*terminations*")} |fl name, distinguishedname
#returns all OU with terminations but does not return the members of that ou.
#returns defined path of an OU and all its members
$password = ConvertTo-SecureString -AsPlainText "Here15448" -Force$users = Get-ADUser -Filter * -SearchBase "OU=Terminations,OU=NYNYC,DC=corp,DC=local"
foreach($user in $users)
{ set-adaccountpassword -id $user -newpassword $password -reset -whatif
disable-adaccount -id $user
}
Aaron Harris ExchangeSharePointGuy