{"record":{"id":"e3b79d5047e8e200","repo":"hashicorp/vagrant","slug":"an-error-occurred-while-executing-a-powershell-scr-e3b79d","errorCode":null,"errorMessage":"An error occurred while executing a PowerShell script. This error\nis shown below. Please read the error message and see if this is\na configuration error with your system. If it is not, then please\nreport a bug.\n\nScript: %{script}\nError:\n\n%{stderr}","messagePattern":"An error occurred while executing a PowerShell script\\. This error\nis shown below\\. Please read the error message and see if this is\na configuration error with your system\\. If it is not, then please\nreport a bug\\.\n\nScript: %(.+?)\nError:\n\n%(.+?)","errorType":"exception","errorClass":"Vagrant::Errors::PowerShellError","httpStatus":null,"severity":"error","filePath":"plugins/hosts/windows/cap/configured_ip_addresses.rb","lineNumber":21,"sourceCode":"\nrequire \"pathname\"\nrequire \"tempfile\"\n\nrequire \"vagrant/util/downloader\"\nrequire \"vagrant/util/file_checksum\"\nrequire \"vagrant/util/powershell\"\nrequire \"vagrant/util/subprocess\"\n\nmodule VagrantPlugins\n  module HostWindows\n    module Cap\n      class ConfiguredIPAddresses\n\n        def self.configured_ip_addresses(env)\n          script_path = File.expand_path(\"../../scripts/host_info.ps1\", __FILE__)\n          r = Vagrant::Util::PowerShell.execute(script_path)\n          if r.exit_code != 0\n            raise Vagrant::Errors::PowerShellError,\n              script: script_path,\n              stderr: r.stderr\n          end\n\n          res = JSON.parse(r.stdout)[\"ip_addresses\"]\n          Array(res)\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":3,"sourceCodeEnd":33,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/hosts/windows/cap/configured_ip_addresses.rb#L3-L33","documentation":"Vagrant::Errors::PowerShellError raised in plugins/hosts/windows/cap/configured_ip_addresses.rb:21. The Windows host capability enumerates the host's IP addresses (used for NFS/network setup) by executing scripts/host_info.ps1 via Vagrant::Util::PowerShell and parsing its JSON stdout; a non-zero exit raises with the script path and stderr.","triggerScenarios":"On a Windows host, any operation needing host IPs runs host_info.ps1; it exits non-zero when the PowerShell execution policy blocks unsigned scripts, the PS installation/module path is broken, or the network cmdlets inside (Get-NetIPAddress etc.) fail.","commonSituations":"ExecutionPolicy Restricted on locked-down machines; a corrupted $env:PSModulePath; WMI/NetTCPIP repository damage; antivirus interfering with script execution.","solutions":["Run the exact Script path from the error in a PowerShell window to see the real error","Allow local scripts: `Set-ExecutionPolicy -Scope CurrentUser RemoteSigned`","Repair the WMI repository if network cmdlets fail (`winmgmt /verifyrepository`, then /salvage if needed)","Update Vagrant; exclude the script from AV interference"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Windows pre-flight: PowerShell present and scripts can run\nraise \"PowerShell unavailable\" unless Vagrant::Util::PowerShell.available?\nps_ok = system(\"powershell -NoProfile -ExecutionPolicy Bypass -Command \\\"[Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces() | Out-Null\\\"\")\nabort \"PowerShell/network cmdlets broken — check ExecutionPolicy and WMI\" unless ps_ok","typeGuard":null,"tryCatchPattern":"begin\n  capability.call(:configured_ip_addresses, env)\nrescue Vagrant::Errors::PowerShellError => e\n  puts \"host_info.ps1 failed:\\n#{e.data[:stderr]}\"\n  # guide user to Set-ExecutionPolicy / WMI repair, then retry\n  raise\nend","preventionTips":["Set ExecutionPolicy RemoteSigned on Windows hosts running Vagrant","Keep $env:PSModulePath intact; don't strip system module paths in profiles","Repair the WMI repository when network cmdlets start failing"],"tags":["windows","powershell","host-info","network","execution-policy"],"backgroundTag":"powershell-script-failed","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}