Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Run a script for user objects in a specific OU, but exclude a few OUs in that OU

$
0
0

Run a script for user objects in a specific OU, but exclude a few OUs in that OU

While the script I have setup doesn't give me any errors, it's not filtering out the OUs I have named in them. I'm somehow missing something.

Powershell
get-aduser-SearchBase"OU=User Accounts,OU=Company Name,DC=company,DC=local"-Filter*-propertiespasswordlastset|?{$_.DistinguishedName-notlike"*OU=Cisco Phone System Accounts,OU=User Accounts,OU=Company Name,DC=company,DC=local*"-and$_DistinguishedName-notlike"*OU=Book,OU=User Accounts,OU=Company Name,DC=company,DC=local*"-and$_DistinguishedName-notlike"*OU=WebAccess,OU=User Accounts,OU=Company Name,DC=company,DC=local*"-and$_DistinguishedName-notlike"*OU=UtilityAccounts,OU=User Accounts,OU=Company Name,DC=company,DC=local*"-and$_DistinguishedName-notlike"*OU=VendorAccounts,OU=User...

Viewing all articles
Browse latest Browse all 15370

Latest Images

Trending Articles



Latest Images

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