hyperv_host_exec
Run PowerShell scripts with Hyper-V administrator rights on the host to perform elevated VM tasks like VHD mounting, GPU partitioning, and VM import or export that a normal shell denies with Access denied.
Instructions
Run a PowerShell script on the HOST machine with Hyper-V administrator rights (elevated). Use this instead of a plain shell tool for any Hyper-V work that needs host administrator access, which a non-elevated shell answers with "Access denied": Get-VMHost*, Get-VMHostPartitionableGpu / Get-VMGpuPartitionAdapter / Add-VMGpuPartitionAdapter, Get-VMProcessor / Set-VMProcessor, Get-VMNetworkAdapter*, Mount-VHD / Dismount-VHD / Optimize-VHD / Resize-VHD / Compare-VHD, Import-VM / Export-VM / Move-VM, Get-VMSnapshot / Checkpoint-VM, Get-VMFirmware / Set-VMFirmware, Get-VMHost*, and reading C:\ProgramData\Microsoft\Windows\Hyper-V (including .vmcx/.vmrs files). Runs on the host, not inside a guest — use hyperv_exec for commands inside a VM. stdout and stderr are merged and returned verbatim, with the elevated process exit code. Elevation is silent when UAC allows it; otherwise the user sees a UAC prompt, and declining it is reported as an error instead of being retried. SCOPE — this tool is for Hyper-V and its virtual machines only. It is not a general administrator shell: do not use it for unrelated system changes, software installation, service or registry edits, reading or writing files the caller could reach by itself, or any script that has nothing to do with Hyper-V or its VMs. If a command needs no host administrator rights, or is not about Hyper-V and its virtual machines, use the ordinary shell tool instead. This boundary is an agreement with the user, not a technical control: nothing in the code rejects a command outside Hyper-V, so keeping to it is the caller's responsibility.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"command": "<command>"
},
"name": "hyperv_host_exec"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | PowerShell source to run elevated on the host. May be multi-line and may contain pipeline syntax; it behaves as one script block. | |
| timeoutMs | No | Overall timeout in milliseconds. Default 120000. | |
| workingDirectory | No | Directory the elevated script starts in. Defaults to the current user's profile directory. Set it explicitly when the script uses relative paths. |