[SOLVED] Windows qm guest exec powershell got timeout

rml

Member
Apr 24, 2019
31
0
11
45
Think I'm being stupid with syntax here, fresh install with Serial drivers and qm guest agents installed

I'm having trouble getting powershell commands working

e.g.
Code:
oot@pve:~# qm guest exec 108 -- "C:\WINDOWS\system32\cmd.exe" "/c"  "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-Command" "dir"
VM 108 qmp command 'guest-exec-status' failed - got timeout

root@pve:~# qm guest exec 108 -- "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-Command" "dir"
VM 108 qmp command 'guest-exec-status' failed - got timeout

root@pve:~# qm guest exec 108 -- C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command dir
Agent error: Guest agent command failed, error was 'Failed to execute child process (No such file or directory)'

Powershell -Command dir works from the guest machine

Thanks in advance

EDITS: rewrote question after solving original cmd.exe problem

I've managed to cmd working
e.g.
qm guest exec 108 -- "C:\WINDOWS\system32\cmd.exe" "/c" "dir"

for me next time:
note the quotes of all all arguments, I did that because I didn't appreciate what the -- was doing so may not be totally necessary but worked
https://unix.stackexchange.com/questions/11376/what-does-double-dash-mean
 
Last edited:
hi,

this works here:
Code:
qm guest exec 2000 "powershell.exe" "whoami"
{
   "exitcode" : 0,
   "exited" : 1,
   "out-data" : "nt authority\\system\r\n"
}

qm guest exec 2000 "powershell.exe" "ls /users/"
{
   "exitcode" : 0,
   "exited" : 1,
   "out-data" : "\r\n\r\n    Directory: C:\\users\r\n\r\n\r\nMode                 LastWriteTime         Length Name                                                                 \r\n----                 -------------         ------ ----                                                                 \r\nd-r---         8/11/2020  12:52 PM                Public                                                               \r\nd-----         4/15/2021  11:31 AM                user                                                                 \r\n\r\n\r\n"
}

no need to separate with -c or /c in powershell case

for cmd the following syntax works:

Code:
qm guest exec 2000 "cmd" "/c whoami"
qm guest exec 2000 "cmd" "/c whoami /all"

hope this helps
 
Last edited:
Clearly overcomplicating it as always, that's really helpful, thanks Oguz
 
just fyi, even easier is it with the '--' separator

Code:
qm guest exec 2000 -- cmd /c whoami

no quoting of the arguments necessary
 
  • Like
Reactions: rml

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!