Hello everyone,
I face this problem on every script, it's hard for me to find root cause, can some one help please? 🙂
My script usually contains following line to load PowerCLI:
add-pssnapin VMware.VimAutomation.Core
Whenever I run it on PowerShell prompt window, it's working fine.
I created scheduled task to run the script daily, first several runs worked fine, but it's pending on load PowerCLI snapin after few days, no error, just pending there.
I tried create task by .ps1 file directly and by .bat, no help.
I tried on PowerShell 2.0 with PowerCLI 5.5 Release 1, and PowerShell 3.0 with PowerCLI 5.5 Release 2, both does not work.
It's not mentioned on PowerCLI release notes.
*****************************************************
My server is Windows Server 2008 R2.
Following is PowerShell version:
Name Value
---- -----
WSManStackVersion 3.0
PSCompatibleVersions {1.0, 2.0, 3.0}
SerializationVersion 1.1.0.1
BuildVersion 6.2.9200.16398
PSVersion 3.0
CLRVersion 4.0.30319.1022
PSRemotingProtocolVersion 2.2
Following is PowerCLI version:
PowerCLI Version
----------------
VMware vSphere PowerCLI 5.5 Release 2 build 1671586
---------------
Snapin Versions
---------------
VMWare AutoDeploy PowerCLI Component 5.5 build 1598391
VMWare ImageBuilder PowerCLI Component 5.5 build 1598391
VMware License PowerCLI Component 5.5 build 1265954
VMware VDS PowerCLI Component 5.5 build 1671576
VMware vSphere PowerCLI Component 5.5 build 1671576
Thanks for your helping LucD, I figured out it.
Please refer my blog for solution!
Sometimes this is caused by warning messages.
Can you try to disable warning messages ?
You can add the line
$WarningPreference = "SilentlyContinue"
to the script.
Or if it's PowerCLI warnings you can do
Set-PowerCliConfiguration - DisplayDeprecationWarnings:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I'm using this line, is that same like your first line?
$ErrorActionPreference = "SilentlyContinue"
Regarding the second line, I guess it's functional after full load VMware.VimAutomation.Core, but my problem is the script looks like pending on load the snapin...
No, that line is to suppress the prompt after an error occurs, the one I mentioned is to suppress an action prompt after a Warning.
Yes, the 2nd one is only valid after you load the PowerCLI pssnapin.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for your helping LucD, I figured out it.
Please refer my blog for solution!
Nice find, thanks for sharing
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference