Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Powerchell: Scan users in multiple AD OU

$
0
0

Hi i have a problem that i need you to help to solve, I want so search through multiple OU´s for Users. I have it working for one OU but i need to make a script that can search through multiple I am currently trying to get it working with two, but i can't seem to get it to work.

Function Update-ADUsers {


Import-Csv -path $csvfile | `

ForEach-Object { 



$Description = $_.'Descripcion'

$sam = $_.'Logon Name'



    Try{ $SAMinAD = Get-ADUser -server $ADServer -Credential $GetAdminact -LDAPFilter "(sAMAccountName=$sam)"}
    Catch{}


    If($SAMinAD -ne $null -and $sam -ne '')
    {
IF ($Description -ne '' ) { Set-ADUser -server $ADServer -Credential $GetAdminact -SearchBase "OU=maincra,DC=depresion,DC=com" -Identity $sam -Replace @{Description = $Description}} 

}
}

    

Viewing all articles
Browse latest Browse all 21975

Trending Articles



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