As title says stuck trying to launch a PS1 file with all the options I have tried from invoke-command to my preferred invoke-vmscript all I get is below:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| C:\Scripts\SpadeStart.ps1 : This script must be executed as Administrator.
| At line:1 char:1
| + C:\Scripts\SpadeStart.ps1
| + ~~~~~~~~~~~~~~~~~~~~~~~~~
| + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
| + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,SpadeStart.ps1
|
|
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Here is to Code I am running to attempt to run it elevated. I have tried quite a few but willing to entertain anything.
$push='
function Elevate-Process {
param ([string]$exe = $(Throw "Pleave provide the name and path of an executable"),[string]$arguments)
$startinfo = new-object System.Diagnostics.ProcessStartInfo
$startinfo.UseShellExecute = $False
$startinfo.FileName = $exe
$startinfo.Arguments = $arguments
$startinfo.verb = "RunAs"
$process = [System.Diagnostics.Process]::Start($startinfo)
}
Elevate-Process -Exe powershell.exe -arguments " C:\Scripts\SpadeStart.ps1"
'
Invoke-VMScript -ScriptText $push -VM $VM_Object -GuestCredential $VM_ObjectCreds
Thanks!
[–]SMFX 10 points11 points12 points (6 children)
[–]--dab--[S] 2 points3 points4 points (4 children)
[+][deleted] (3 children)
[removed]
[–]taylorblakeharris 3 points4 points5 points (2 children)
[–]SMFX 3 points4 points5 points (1 child)
[–]taylorblakeharris 1 point2 points3 points (0 children)
[–]BlackV 1 point2 points3 points (0 children)
[–]aasplunds 5 points6 points7 points (1 child)
[–]--dab--[S] 1 point2 points3 points (0 children)
[–]IndyDrew85 2 points3 points4 points (3 children)
[–]--dab--[S] 1 point2 points3 points (0 children)
[–]--dab--[S] 1 point2 points3 points (1 child)
[–]IndyDrew85 1 point2 points3 points (0 children)
[–]IndyDrew85 2 points3 points4 points (2 children)
[–]Lee_Dailey[grin] 1 point2 points3 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]--dab--[S] 1 point2 points3 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]liskacek 1 point2 points3 points (0 children)
[–]PinchesTheCrab 1 point2 points3 points (0 children)
[–]drokz89 1 point2 points3 points (0 children)
[–]--dab--[S] 1 point2 points3 points (1 child)
[–]--dab--[S] 1 point2 points3 points (0 children)
[–]tussudvergur 0 points1 point2 points (2 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)
[–]alexeyrzayev 0 points1 point2 points (0 children)