如何从远程以管理员身份从powershell中的脚本安装软件

如何从远程以管理员身份从powershell中的脚本安装软件,powershell,Powershell,我想运行这个没有任何互动作为管理员?如何在具有管理员权限的远程计算机上运行powershell脚本 $Path = $env:TEMP; $Installer = "dotner_installer.exe"; Invoke-WebRequest "https://go.microsoft.com/fwlink/?linkid=2088631" -OutFile $Path\$Installer; Start-Process -FilePath $Path

我想运行这个没有任何互动作为管理员?如何在具有管理员权限的远程计算机上运行powershell脚本

$Path = $env:TEMP; $Installer = "dotner_installer.exe"; Invoke-WebRequest "https://go.microsoft.com/fwlink/?linkid=2088631" -OutFile $Path\$Installer; Start-Process -FilePath $Path\$Installer -Args "/y /silent /install" -Verb RunAs -Wait; Remove-Item $Path\$Installer 

如果通过PSSession连接,则默认情况下,远程计算机上的会话具有管理员权限。使用
Invoke命令
直接在目标上执行脚本,或
输入PSSession
手动执行脚本。您可以使用
New PSSession
创建会话,以将会话存储在变量中,并将其用于多个cmdlet

$Session = New-PSSession -ComputerName targetPC #-Credential if\needed


Invoke-Command -Session $Session -ScriptBlock {
    $Path = $env:TEMP; 
    $Installer = "dotner_installer.exe"; 
    Invoke-WebRequest "https://go.microsoft.com/fwlink/?linkid=2088631" -OutFile $Path\$Installer; 
    Start-Process -FilePath $Path\$Installer -Args "/y /silent /install" -Verb RunAs -Wait; 
    Remove-Item $Path\$Installer 
} -ArgumentList $IfYouHaveSome

我正在通过管道连接到azure vm,因此它将是非交互的,它将在没有交互模式的情况下运行,我不认为上述情况会发生work@itye1970现在它是100%无交互。。。如果在Azure VM上启用了PSSession(
启用PSSession
),它也应该在那里工作。。。如果不起作用,请使用