powershell,活动目录,用于获取和设置Office用于工作的脚本,现在不行

时间:2012-03-20 20:29:06

标签: powershell

我正在使用几年前使用的这个脚本来修复AD树中学生的办公室价值,以验证新qa域上的内容是否仍然正确设置以运行广告脚本

import-module ActiveDirectory

#$Users = Get-ADUser -Filter 'UserPrincipalName -like "*"' -Properties * 
$Users = Get-ADUser -Filter "Office -like 'Gary' -and (UserPrincipalName -like '*Abair.Dezaerae*' ) -and DisplayName -like'*Alumni*'" -Properties *

Write-Host $Users
foreach($User in $Users)
{
    Write-Host $User.SamAccountName;
    $User.SamAccountName;
    [System.String]$newOffice = "Gary Alumni"

    Set-ADUser -Identity $User.SamAccountName -Office $newOffice 
}

我收到了这个错误,

Set-ADUser : Cannot validate argument on parameter 'Identity'. The argument is null. Supply a non-null argument and try the command again.
At line:13 char:25
+ Set-ADUser -Identity <<<<  $User.SamAccountName -Office $newOffice 
    + CategoryInfo          : InvalidData: (:) [Set-ADUser], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.ActiveDirectory.Management.Commands.SetADUser

但是如果用户为空,那么它甚至不会命中第13行,对吗?

可能在服务器配置上更改了somethign以破坏此脚本吗? 我在QA域控制器上实际运行它,我很确定上次我们在PROD上执行它,所以QA可能从未正确配置。

任何想法让IT人看到什么?

1 个答案:

答案 0 :(得分:0)

IT人员走了,摆弄,并说“在后台复制的东西”,现在它的工作原理......对不起,我不能给出更有帮助的答案但是......在这个问题上你的IT团队生病了。 / p>

相关问题