【发布时间】:2021-01-19 17:45:31
【问题描述】:
假设我有一个脚本:Install.ps1
作为管理员,我希望能够为指定用户运行此脚本:joe.smith
Joe.smith 不是管理员。 所有这些都应该在 localhost 上完成,无需远程到另一台计算机。
我尝试过的事情:
new-pssession localhost -credential SSN314\joe.smith
错误:new-pssession:[localhost] 连接到远程服务器 localhost 失败,并显示以下错误消息:访问是 否认。有关详细信息,请参阅 about_Remote_Troubleshooting 帮助主题。
我也试过了:
$username = "joe.smith"
$password = "pass"
$secstr = New-Object -TypeName System.Security.SecureString
$password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, $secstr
Invoke-Command -FilePath "C:\dir\Install.ps1" -Credential $cred -ComputerName "."
Joe.smith 不是管理员,这就是我认为我收到拒绝访问错误的原因。
joe.smith 是一个域帐户。
当我运行以下命令时,joe.smith 可以完全控制:Set-PSSessionConfiguration -ShowSecurityDescriptorUI -Name Microsoft.Powershell 命令
感谢任何帮助。
【问题讨论】: