简体   繁体   中英

Set-ADuser in Foreach

I tried to set the value Company into the ad field Company and it should Filter by Homepage (this works). And I get this error:

cmdlet Set-ADUser at command pipeline position 1 Supply values for the following parameters: Identity:

$users = $null

$users = Get-ADUser -Filter 'Homepage -like "www.test.ch"' -Searchbase “OU=TestOu, OU=test Lyss, DC=ads,DC=test,DC=CH"  



ForEach($user in $users)
{
    
    Set-ADUser -Identity -Company 'Company' 

}

Right, in your foreach loop, you're calling the -Identity parameter but never giving any value to the argument, like -Identity $user . In addition, it can be piped directly:

Get-ADUser -Filter "Homepage -like 'www.test.ch'" -Searchbase 'OU=TestOu,OU=test Lyss,DC=ads,DC=test,DC=CH' |
Set-ADUser -Company 'Company'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM