Running a PowerShell Command via 'pvesh create exec' Inside a VM

Aug 16, 2024
2
0
1
Good day,

I am trying to run the command "powershell.exe -NoProfile -ExecutionPolicy Bypass -File C:/install/rename_nics.ps1" from the CLI of Proxmox.

When I execute the following:
pvesh create /nodes/$(hostname)/qemu/${VM_ID}/agent/exec --command "powershell.exe" --command "-NoProfile -ExecutionPolicy Bypass -File C:/install/rename_nics.ps1"

It appears to run, and I receive a PID, but then I encounter an error.

It seems like the arguments are not being transferred correctly.
1723844577313.png

at the eventlog:
1723845705123.png

What is the correct way to pass arguments in a command?
 
Last edited:
Hi,

try
Code:
pvesh create /nodes/$(hostname)/qemu/${VM_ID}/agent/exec --command 'powershell.exe' --command 'Set-ExecutionPolicy bypass -scope Process -force; C:\install\rename_nics.ps1'

Regards
 
  • Like
Reactions: razul187