使用Invoke-Command时具有较高的权限

问题描述 投票:2回答:1

我正在尝试使用Invoke-Command将MSI部署到远程计算机,请参阅下文。

如果我以“ Domain \ Administrator”的身份运行此脚本,它将起作用,如果我尝试以指定的帐户运行此脚本,则MSI无法安装。我已经验证了我正在运行的帐户,因为该帐户在所有服务器上都具有本地管理员权限。

如果它是本地管理员的成员,是否可以通过PowerShell来提升帐户的权限?

我想避免在脚本本身中保存凭据。

$cred = Get-Credential
$MSISource = "E:\DeploymentTool\Deploy.msi"
$csv = Import-Csv "C:\Scripts\Deploylist.csv"
$csv | ForEach-Object {
    $Server = $_.Server
    Copy-Item $MSISource -Destination "\\$Server\E$\temp\Deploy.msi" -Force 
    Invoke-Command -ComputerName $Server -Credential $Cred -ScriptBlock {
        Msiexec /i "E:\temp\Deploy.msi" /quiet /qn /norestart /log E:\temp\MSIInstall.txt
    }
powershell elevated-privileges
1个回答
0
投票

我有类似的问题。我想使用invoke-command在远程计算机中安装node.msi。

对于海拔,我们可以在Start-Process命令中使用-Verb RunAs。更新的代码如下所示。

$cred = Get-Credential
$MSISource = "E:\DeploymentTool\Deploy.msi"
$csv = Import-Csv "C:\Scripts\Deploylist.csv"
$csv | ForEach-Object {
    $Server = $_.Server
    Copy-Item $MSISource -Destination "\\$Server\E$\temp\Deploy.msi" -Force 
    Invoke-Command -ComputerName $Server -Credential $Cred -ScriptBlock {
        start-process powershell.exe -verb runas -argumentlist ('Msiexec /i "E:\temp\Deploy.msi" /quiet /qn /norestart /log E:\temp\MSIInstall.txt')}

现在,如果这给具有本地管理员权限的帐户带来以下错误,则为错误。

由于以下错误而无法运行此命令:此操作需要交互式窗口站。

我在注册表中做了以下更改,因为不存在使它起作用的键-

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.