tdubb123
Expert
Expert

invoke-vmscript with uac turned off issues

Jump to solution

i try to use following to set static IP settings but getting the error. I have UAC turnd off. I trid using local administrator

 

The request operation requires elevation (run as administrator)

 

Function Set-WinVMIP {

    param(

        [string]$VM,

        [string]$IP,

        [string]$SNM,

        [string]$GW,

        [string]$DNS1,

        [string]$DNS2

      )

   

$cmd = @"

netsh interface ip set address "Ethernet0" static $IP $SNM $GW 1"

netsh interface ip add dns name="Ethernet0" source=static addr=$DNS1 register=primary

netsh interface ip add dns name="Ethernet0" source=static addr=$DNS2 index=2

"@

$xxx = get-credential

Invoke-vmscript -scripttext ($ExecutionContext.InvokeCommand.ExpandString($cmd)) -scriptType bat -VM $VM -guestcredential $xxxx

}

 

any idea

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

Bypassing UAC borders on hacking, so no game in this community I'm afraid.
See a similar discussion in Bypass UAC with invoke-vmscript - VMware Technology Network VMTN

There are apparently some ways to bypass UAC, but again that is hacking.
Try Googling UAC, scheduled task, and schtasks, you might find some tips


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership

Bypassing UAC borders on hacking, so no game in this community I'm afraid.
See a similar discussion in Bypass UAC with invoke-vmscript - VMware Technology Network VMTN

There are apparently some ways to bypass UAC, but again that is hacking.
Try Googling UAC, scheduled task, and schtasks, you might find some tips


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
tdubb123
Expert
Expert

ok thanks Luc

0 Kudos