0

I have a python that uses pyvmomi library of VMWare to perform operations on remote VM. I open the remote VM cmd prompt using Pyvmomi library like this

vim.vm.guest.ProcessManager.ProgramSpec(
        programPath="C:\\Windows\\System32\\cmd.exe")

Is there any way to open Power Shell as Admin or any code that can be added in the script to run it as Admin.

user1312155
  • 173
  • 4
  • 13

1 Answers1

0

You have to run the powershell script as administrator:

https://stackoverflow.com/a/25247612/1763602

You can create another script that will launch your script with elevated privileges.

Community
  • 1
  • 1
Marco Sulla
  • 15,299
  • 14
  • 65
  • 100
  • @Macro Sulla - as said on the link u specify i do RUNAS /user:user@domain.microsoft.com "powershell pshell.ps1" it ask for admin passwd – user1312155 Jul 24 '16 at 11:56
  • @user1312155: there are other solution listed in the answer. One is `psexec`: http://ss64.com/nt/psexec.html If you don't have it, you have to install Sysinternal tools. – Marco Sulla Jul 24 '16 at 21:51
  • @Macro Sulla i can't use any other tool except VMWare Tools – user1312155 Jul 25 '16 at 03:59
  • You can run `runas` with `/savecred` on VM, password will be stored. I don't linke this solution for security reasons, but it will work. That said, `pstools` are now an official Microsoft tool and needs no install. – Marco Sulla Jul 25 '16 at 13:50