6 Comments

  1. Working with a large number of users you would probably want to do a LdapFilter instead.

    Get-ADUser -LDAPFilter “(!ScriptPath=*)”

    If you don't, the Get-ADUser will return _every_ user in the OU and then the Where-Object will do the filtering…

  2. Bill Parsons

    # To make this script run a little bit faster, and believe me it does in larger environments, you can specify just
    # the scriptpath property. As Name is a default property already to be returned, the script runs much faster,
    # not having to retrieve all properties. Also by specifying in your ‘where’ statement ‘and Enabled is True’ it will only # return Enabled Accounts, which is probably all you care about. Just thought I’d Share. 🙂
    $ou = “OU=testing,DC=localDC,DC=com”
    Get-ADUser -SearchBase $ou -Filter * -Properties ScriptPath | where { ($_.ScriptPath -eq $null) -and ($_.Enabled -eq $True)} | select Name

  3. Kim

    Does anybody know the script where I can get all properties of all users in AD
    which are null for example telephone, streetaddress etc

  4. Brandon

    I want to clear the scriptpath for all users in AD ONLY if the current scriptpath equals a certain .bat file. How would I go about that?

Leave a Reply