Quantcast
Channel: Directory Services forum
Viewing all articles
Browse latest Browse all 31638

Powershell Script replace an attribute Value for User in AD

$
0
0

Hi everything is in the title, 

I want to replace the info attribute of my AD user by 1 or 0 depending of what is write in IT

if into the info attribute it's "INT" what is write then it will replace by 1 and if it is "EXT" it will replace by 0

here is my script it works without errors but it do nothing

Import-Module ActiveDirectory

$_ = Get-ADUser -filter {Enabled -eq $True } | select info | foreach { 

    if($_.info -eq "INT"){

    set-ADUser -Identity $_ -Replace @{info= "1"}
        
    }
    
    elseif ($_.info -eq "EXT") {

        set-ADUser -Identity $_ -Replace @{info= "0"}
    }

}

Thank You 

Viewing all articles
Browse latest Browse all 31638

Latest Images

Trending Articles



Latest Images

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