下面的代码工作正常,当我在PowerShell ISE中运行它以管理员身份(即我开始PS ISE作为管理员)调用命令运行作为管理员OK,但不作为当前用户
Invoke-Command -ScriptBlock {[IntPtr]::Size}
Invoke-Command -ScriptBlock {[IntPtr]::Size} -ComputerName $env:COMPUTERNAME -Credential $Credential
Invoke-Command -ScriptBlock {[IntPtr]::Size} -ComputerName $env:COMPUTERNAME -Credential $Credential -ConfigurationName Microsoft.PowerShell32
我得到的
8
8
4
所期望的响应这告诉我,WinRM的正确配置和运行,并且我的$凭证是正确的设置。然而,当我尝试运行在PS ISE同一个用户(有或没有管理员权限),我收到以下错误,第二个和第三个命令
[<ComputerName>] Connecting to remote server <ComputerName> failed with the following error message : Access is denied. For more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (<ComputerName>:String) [], PSRemotingTransportException
+ FullyQualifiedErrorId : AccessDenied,PSSessionStateBroken
我将取代更多的东西的脚本块码由于依赖于32位DLL,因此需要以32位模式运行,并且用户能够以64位模式运行部分代码,而在32位模式下运行其他部分则非常重要。
有什么想法?
凭证是否与您的登录相同? – Jimbo
@Jimbo - 是的,这就是为什么这是如此混乱。此外,在管理员或用户模式下相同的cerdential,并且在管理员模式下工作正常。 – hsbatra