Skip to content

hyperv: avoid CLR type conversion for VirtualMachine under pwsh - #13844

Open
r3wretrhy wants to merge 1 commit into
hashicorp:mainfrom
r3wretrhy:fix-hyperv-pwsh-vm-type
Open

r3wretrhy wants to merge 1 commit into
hashicorp:mainfrom
r3wretrhy:fix-hyperv-pwsh-vm-type

Conversation

@r3wretrhy

Copy link
Copy Markdown

hyperv: avoid CLR type conversion for VirtualMachine under pwsh

PowerShell 7 loads Hyper-V's VirtualMachine from Microsoft.HyperV.PowerShell.Objects.dll, while Vagrant's wrappers annotate $VM as Microsoft.HyperV.PowerShell.VirtualMachine from Microsoft.HyperV.PowerShell.dll. Those are different CLR types with the same name, so Set-VagrantVMCPUS and the other five wrappers fail with a conversion error. Windows PowerShell 5.1 does not hit this.

Use PSTypeName so the wrappers check the type name without assembling a conversion. VAGRANT_PREFERRED_POWERSHELL=powershell remains a workaround.

Fixes #13841

@r3wretrhy
r3wretrhy requested a review from a team as a code owner September 16, 2026 16:40
@hashicorp-cla-app

hashicorp-cla-app Bot commented Sep 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@hashicorp-cla-app

Copy link
Copy Markdown

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes

Have you signed the CLA already but the status is still pending? Recheck it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hyper-V provider fails under PowerShell 7 due to duplicate VirtualMachine CLR types

1 participant