【问题标题】:Powershell Issue: Trying to run an install script for a non administrative userPowershell 问题:尝试为非管理用户运行安装脚本
【发布时间】: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 命令

感谢任何帮助。

【问题讨论】:

    标签: powershell remote-access


    【解决方案1】:

    我看到的问题是您正在尝试远程访问本地 PC。您应该可以改用Start-Process

    Start-Process powershell.exe -ArgumentList "-file","C:\dir\Install.ps1" -Credential $cred
    

    【讨论】:

    • 现在它说我的目录名是无效的,但显然不是。
    猜你喜欢
    • 1970-01-01
    • 2019-03-30
    • 2019-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-22
    • 2022-01-08
    相关资源
    最近更新 更多