Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

PowerShell Find all OU with group folder named Terminations

$
0
0

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


Viewing all articles
Browse latest Browse all 15028

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>