I've noticed that some members of this forum are writing code in Powershell v2 (like LucD), so I've updated my PowerShell to 2.0 CTP available here: http://support.microsoft.com/kb/968929. I have to do the CTP as I'm still on Windows XP.
I've uninstalled and reinstalled PowerCli 4.0 U1, at the end of the installation I allow the wizard to start a PowerCli window for me, that works great. But when I use the desktop or start menu icon I get:
There were errors in loading the format data file:
VMware.VimAutomation.Core, , C:\Program Files\VMware\Infrastructure\vSphere Powe
rCLI\VMware.VimAutomation.Format.ps1xml : File skipped because of the following
validation exception: File C:\Program Files\VMware\Infrastructure\vSphere PowerC
LI\VMware.VimAutomation.Format.ps1xml cannot be loaded because its execution is
blocked by software restriction policies. For more information, contact your sys
tem administrator..
writeErrorStream : True
Exception : System.Management.Automation.PSSecurityException: File
C:\Program Files\VMware\Infrastructure\vSphere PowerCL
\Scripts\Initialize-VIToolkitEnvironment.ps1 cannot be
loaded because its execution is blocked by software re
triction policies. For more information, contact your
ystem administrator. ---> System.UnauthorizedAccessExc
ption: File C:\Program Files\VMware\Infrastructure\vSp
ere PowerCLI\Scripts\Initialize-VIToolkitEnvironment.p
1 cannot be loaded because its execution is blocked by
software restriction policies. For more information, c
ntact your system administrator.
--- End of inner exception stack trace ---
at System.Management.Automation.AuthorizationManage
.ShouldRunInternal(CommandInfo commandInfo, CommandOri
in origin, PSHost host)
at System.Management.Automation.CommandDiscovery.Sh
uldRun(ExecutionContext context, PSHost host, CommandI
fo commandInfo, CommandOrigin commandOrigin)
at System.Management.Automation.CommandDiscovery.Lo
kupCommandProcessor(CommandInfo commandInfo, CommandOr
gin commandOrigin, Nullable`1 useLocalScope)
at System.Management.Automation.CommandDiscovery.Lo
kupCommandProcessor(String commandName, CommandOrigin
ommandOrigin, Nullable`1 useLocalScope)
at System.Management.Automation.CommandFactory._Cre
teCommand(String commandName, CommandOrigin commandOri
in, Nullable`1 useLocalScope)
at System.Management.Automation.ExecutionContext.Cr
ateCommand(String command)
at System.Management.Automation.CommandNode.CreateC
mmandProcessor(Int32& index, ExecutionContext context)
at System.Management.Automation.CommandNode.AddToPi
eline(PipelineProcessor pipeline, ExecutionContext con
ext)
at System.Management.Automation.PipelineNode.Execut
(Array input, Pipe outputPipe, ArrayList& resultList,
xecutionContext context)
at System.Management.Automation.StatementListNode.E
ecuteStatement(ParseTreeNode statement, Array input, P
pe outputPipe, ArrayList& resultList, ExecutionContext
context)
TargetObject :
CategoryInfo : NotSpecified: ( [], PSSecurityException
FullyQualifiedErrorId : RuntimeException
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
PipelineIterationInfo : {}
PSMessageDetails :
PS C:\> Get-ExecutionPolicy
Unrestricted
Any ideas? Should I forget about Powershell v2?
Ben
You don't have to use v2 CTP because you're on XP.
There is a v2 RTM for XP as well, you can find it here.
Note that PS v2 is now part of what MS calls Windows Management Framework Core.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I have installed that (http://support.microsoft.com/kb/968929), so I guess I'm not running a CTP.
But, since Build and Revision show '-1' doesn't that mean I'm running CTP?
PS C:\> $host.version
Major Minor Build Revision
-
-
-
-
2 0 -1 -1
I've installed from: WindowsXP-KB968930-x86-ENG.exe
I think the weird thing is that PowerCli works when launching from the setup wizard but it fails when launching from the icon. The icon launches:
C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -psc "C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -noe -c ". \"C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-VIToolkitEnvironment.ps1\""
Process explorer shows nothing in the 'command line' for the PowerCli window launched from the wizard, it shows the above info when I launch from an icon (but it does not work).
Thoughts?
Ben
Use
$PSVersionTable
to see the PS version and build.
If the build says 6.0.6002.18111 (under XP !) you have PS v2.
I suspect the -1 values in the $host.version property mean "not applicable" or "not used" and can be ignored.
Did you upgrade an existing VI Toolkit 1.5 ?
In that case the folder is not correct in the icon.
It should be
C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -psc "C:\Program Files\VMware\Infrastructure\VIToolkitForWindows\vim.psc1" -noe -c ". \"C:\Program Files\VMware\Infrastructure\VIToolkitForWindows\Scripts\Initialize-VIToolkitEnvironment.ps1\""
Update the icon's target accordingly and try to launch.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I am in fact running a RTM version, thx for your help.
After some Googling searching for "powershell "blocked by software restriction policies"" I found this:
http://activeroles.inside.quest.com/thread.jspa?threadID=10037&tstart=74
I did see an Untrusted cert publisher in IE from VMWare set to expire 10/2010. I removed it and bam, powercli starts from the icon...
Ben
Thanks for posting that. That fixed my issue as well.