Powershell help

Home Forums Scripting PowerShell Powershell help

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    joeln
    Member
    #145959

    I have a Powershell script to list all disable AD users in a domain. I need to alter it to exclude certain OU’s, but have no idea how. Any thoughts? The script (from MS) is below. Thanks

    $strFilter = “(&(objectCategory=User)(userAccountControl:1.2.840.113556.1.4.803:=2))”

    $objDomain = New-Object System.DirectoryServices.DirectoryEntry

    $objSearcher = New-Object System.DirectoryServices.DirectorySearcher
    $objSearcher.SearchRoot = $objDomain
    $objSearcher.PageSize = 1000
    $objSearcher.Filter = $strFilter

    $colProplist = “name”
    foreach ($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i)}

    $colResults = $objSearcher.FindAll()

    foreach ($objResult in $colResults)
    {$objItem = $objResult.Properties; $objItem.name}

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.