I recently had the need to do some reporting on a XenServer 6.0 environment, so thought I’d take a look at what was available through the XenServer 6.0 Powershell snapins. I’d installed it a while back, but hadn’t had the opportunity/time/reason to use it until today. However, when attempting to run it from the shortcut created on the start menu, I was met with the following error:
Command ‘if ($(Get-ExecutionPolicy) -ne “Restricted”) { . . \Initialize-Environment.ps1 } else { Write-Warning “Execution Policy is set to Restricted. Some XensServer commands are disabled.” } ; ‘ could not be executed because some Windows PowerShell snap-ins did not load.
It seems the reason for this is that the shortcut uses the default PowerShell for the server it is run on. When attempting to run on a x64 platform (in this case Windows 2008 R2), it results in the error shown above. In order to get it working I had to run the Powershell executable from ‘syswow64’ rather than from the c:\windows\system32 directory:
From here you can run the XenServerPSSnapIn.bat file, which should now run successfully:
For convenience, you might want to edit the shortcut so that the SysWow64 version of Powershell is called.