VMware Cloud Community
gosst
Contributor
Contributor
Jump to solution

Shutdown Guests via PowerCLI

What is wrong with my script?

 

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Looks like PowerShell can't find the PowerCLI modules.
Where are the modules?
And what is in $env:PSModulePath?

Is the folder where PowerCLI is installed included in there?


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

View solution in original post

Reply
0 Kudos
18 Replies
LucD
Leadership
Leadership
Jump to solution

Looks like PowerShell can't find the PowerCLI modules.
Where are the modules?
And what is in $env:PSModulePath?

Is the folder where PowerCLI is installed included in there?


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

Reply
0 Kudos
gosst
Contributor
Contributor
Jump to solution

C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Modules\

i don't know.
i don't know.
See attachment if that helps.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

That looks to be a rather old PowerCLI version.

Can you remove those folders, and then do an Install-Module -Name VMware.PowerCLI from the PS prompt?


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

Reply
0 Kudos
gosst
Contributor
Contributor
Jump to solution

 
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Looks like this one Unable to install NuGet provider for PowerShell





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

Reply
0 Kudos
gosst
Contributor
Contributor
Jump to solution

Thanks.
I tried that and it worked.
But now when I go back to try and update the modules, not sure it went all the way through.
It went to complete almost all the way, then I got some kind of red error.
Already closed out of it, so it won't show it to me again if I run the same cmd.
I checked the Modules folder. It's still empty; no new modules installed.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Add the Verbose switch on the Install-Module cmdlet.

Install-Module -Name VMware.PowerCLI -Verbose

Run this from a PS prompt, not from within the editor.


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

Reply
0 Kudos
gosst
Contributor
Contributor
Jump to solution

I got this in return (attached).
And the Modules folder is still empty.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Looks like PowerCLI is installed.
Check with

Get-Module -Name VMware* -ListAvailable

The modules are probably installed in one of the official module folders.


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

Reply
0 Kudos
gosst
Contributor
Contributor
Jump to solution

Yup. I got a bunch of results. Now how do I get my script to work?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Did you already try to run your script, after installing the PowerCLI modules?


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

Reply
0 Kudos
gosst
Contributor
Contributor
Jump to solution

Yes

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

I think the error message is clear, the Connect-VIServer can't reach your VCSA.


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

Reply
0 Kudos
gosst
Contributor
Contributor
Jump to solution

I finally got it figured out. Now I just have 1 warning showing.

"WARNING: GuestID property is deprecated. Please use ConfiguredGuestId and RunTimeGuestId properties instead."

I don't have GuestID in my script, so not sure why I see that. Not sure where to put the newer codes at and what to put with it.

Here is my current script:
connect-VIServer -Server Server1.Domain.com -Protocol HTTPS

Set-PowerCLIConfiguration -InvalidCertificateAction ignore -Confirm:$false
SHUTDOWN-VMGuest -VM Server2 -Confirm:$false
SHUTDOWN-VMGuest -VM Server3 -Confirm:$false

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You can safely ignore that warning


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

Reply
0 Kudos
gosst
Contributor
Contributor
Jump to solution

So even though it's deprecated, I shouldn't ever have to update my code in the future if one of those codes becomes obsolete, as the error suggests?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

That warning has been there for quite some time now.
Since you are actually not using that parameter, you shouldn't have to update your code.


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

Reply
0 Kudos
gosst
Contributor
Contributor
Jump to solution

Awesome, thanks.

Reply
0 Kudos