我厌倦了谷歌和搜索,不知道如何让这个条件起作用。
内容userid.txt
:
user1
user2
内容phone.txt
:
phone1
phone2
代码:
$u = Get-Content(".\Desktop\Cubicle\userid.txt")
$p = Get-Content(".\Desktop\Cubicle\phone.txt")
foreach($uf in $u){foreach($pf in $p){Set-AdUser $uf -officephone $pf}}
错误:
Set-ADUser : replace
At line:1 char:49
+ foreach($uf in $u){foreach($pf in $p){Set-AdUser <<<< $uf -officephone $pf}}
+ CategoryInfo : InvalidOperation: (user1:ADUser) [Set-ADUser], ADInvalidOperationException
+ FullyQualifiedErrorId : replace,Microsoft.ActiveDirectory.Management.Commands.SetADUser
Set-ADUser : replace
At line:1 char:49
+ foreach($uf in $u){foreach($pf in $p){Set-AdUser <<<< $uf -officephone $pf}}
+ CategoryInfo : InvalidOperation: (user2:ADUser) [Set-ADUser], ADInvalidOperationException
+ FullyQualifiedErrorId : replace,Microsoft.ActiveDirectory.Management.Commands.SetADUser
如果将来我需要调用 3 个以上的文本文件,我该如何输入?