I'm trying to run invoke-command to launch a powershell script in a powershell file
on a remote computer
. I'm using the credentials for a user with Administrator privilege
. The command needs to be executed by running powershell as an administrator
. There are licensing issues with the application that i'm trying to invoke using the powershell script, so i cannot change the credentials to Administrator but need to run with that particular user itself. I have tried using -RunAsAdministrator
at the end of the Invoke-Command, but i got an error saying:
Invoke-Command : Parameter set cannot be resolved using the specified named parameters.
$command = {
cd Folder
C:\Folder\build.ps1
}
Invoke-Command -ComputerName $RemoteSystemIP -ScriptBlock $command -credential $Credentials1 -ErrorAction Stop -AsJob
I'm trying to execute this as a background job that's why i added the -AsJob
parameter.
Its been several days and i haven't found a solution yet.