I'm trying to deploy an MSI to remote computers using Invoke-Command
, please see below.
It works if I run this script as "Domain\Administrator", if I try to run this as a specified account then MSI fails to install. I have verified the account I'm running this as has local admin rights on all servers.
Is there a way to get PowerShell to elevate the permissions of the account if it's a member of local admins?
I want to avoid saving credentials in the script itself.
$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
}