VMware Cloud Community
npiron
Enthusiast
Enthusiast
Jump to solution

Error running vCheck from cmd file

Hello,

I always use vCheck from http://www.virtu-al.net/ to gather information from our environment.

I am currently setting up a new vSphere 6 environment.

I use PowerCLI 6.0 Release 1 - OS is Windows Server 2012 R2

I wrote a .cmd file to start vCheck:

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -Psc "D:\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" " &  "D:\Scripts\vCheckNew\vCheck.ps1"

I also tried with this one:

powershell.exe -Psc "D:\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -noe -file  "D:\Scripts\vCheckNew\vCheck.ps1"

Both are giving me the same output:

Windows PowerShell terminated with the following error:

Unknown element PSModules found. "PSConsoleFile" should have "PSVersion" and "PSSnapIns" elements only.

I already tried to Google it but no result...

It was working on my previous 5.0 & 5.5 setup.

Maybe there are some powershell policies or something else? I put the Execution Policy to ByPass

Thanks in advance for your help!

1 Solution

Accepted Solutions
sneddo
Hot Shot
Hot Shot
Jump to solution

You don't need the .psc- vCheck loads all requirements as part of the initialization anyway. Remove this and it should just work...certainly working for me with PowerCLI 6.0 R1 on 2012.

View solution in original post

0 Kudos
10 Replies
LucD
Leadership
Leadership
Jump to solution

Are you also using PowerCLI 6 ?

Do a Get-PowerCLIVersion


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
npiron
Enthusiast
Enthusiast
Jump to solution

Yes as I specified.

Here is the full output:

PowerCLI Version

----------------

   VMware vSphere PowerCLI 6.0 Release 1 build 2548067

---------------

Component Versions

---------------

   VMWare AutoDeploy PowerCLI Component 6.0 build 2358282

   VMWare ImageBuilder PowerCLI Component 6.0 build 2358282

   VMware License PowerCLI Component 6.0 build 2315846

   VMware vSphere PowerCLI Component 6.0 build 2548068

   VMware vSphere Update Manager PowerCLI 6.0 build 2503190

   VMware Cloud Infrastructure Suite PowerCLI Component 6.0 build 2548068

   VMware HA PowerCLI Component 6.0 build 2510422

   VMware PowerCLI Component for Storage Management 6.0 build 2522368

   VMware VDS PowerCLI Component 6.0 build 2548068

Thanks in advance!

0 Kudos
LucD
Leadership
Leadership
Jump to solution

I'm afraid PowerCLI 6 R1 broke that functionality of the PSConsoleFile, the PSModules keyword is not supported in a proper .psc1 file I'm afraid.

And you can't change the content of the .psc1 file since it is used by the Initialize-PowerCLIEnvironment.ps1 script, which runs when you start the PowerCLI prompt.

An alternative is to perform the loading of the pssnapins and modules in the profile script of the account you use to run the scheduled task.

Not as handy as before, but it's the least cumbersome alternative I currently see.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

npiron
Enthusiast
Enthusiast
Jump to solution

Thanks a lot LucD for clarifying this!

Too bad that it has changed... I hope that I will not be impacted by other changes...

0 Kudos
LucD
Leadership
Leadership
Jump to solution

I might have a bypass, hold on.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
TrevorBlack
Enthusiast
Enthusiast
Jump to solution

I'm in the same boat. Smiley Sad

0 Kudos
sneddo
Hot Shot
Hot Shot
Jump to solution

You don't need the .psc- vCheck loads all requirements as part of the initialization anyway. Remove this and it should just work...certainly working for me with PowerCLI 6.0 R1 on 2012.

0 Kudos
npiron
Enthusiast
Enthusiast
Jump to solution

Thanks a lot sneddo, it worked just removing this argument...

0 Kudos
jrr001
Enthusiast
Enthusiast
Jump to solution

I upgraded to PowerCLI 6 release 1 and it broke my scheduled task also. I removed the -PSC but still has issue.

Can you explain how to do this workaround you mentioned:

"An alternative is to perform the loading of the pssnapins and modules in the profile script of the account you use to run the scheduled task."

I would appreciated it!

0 Kudos
sneddo
Hot Shot
Hot Shot
Jump to solution

Run Powershell as the user you are using the schedule the task, then run vCheck. That should let you know where it is getting held up.

0 Kudos