我想对具有凭据的有效ADSI对象执行属性值更新...
$myCredential = Get-Credential myDomain\myAdmin
$myScriptBlock = {
[ADSI]$adsiUser = "LDAP://CN=... this is a valid, existing user's distinguishedname value"
$adsiUser.Put('title', 'myTilte')
$adsiUser.SetInfo()
}
此行有效,并且用户的title属性为SET
Invoke-Command -ScriptBlock $myScriptBlock
此行不起作用
Invoke-Command -ScriptBlock $myScriptBlock -Credential $myCredential
有错误...
Invoke-Command : Parameter set cannot be resolved using the specified named parameters.
At line:17 char:1
+ Invoke-Command -ScriptBlock $myScriptBlock -Credential $myCredential
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-Command], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.PowerShell.Commands.InvokeCommandCommand
我可以...但是我真的不想以myAdmin用户的名义运行powershell ...我更愿意使用凭据...