VMware Cloud Community
piercj2
Enthusiast
Enthusiast
Jump to solution

PowerCLI 10 (and Microsoft VS Code)

Hi All,

Earlier today when trying to do some basic work in PowerCLI on a vCenter 6.5 server, I started to see some strange results

PS C:\WINDOWS\system32> Get-VMHost $serverlist | Get-VM

Get-VM : 26/Jun/2018 13:26:31    Get-VM        Exception has been thrown by the target of an invocation.   

At line:1 char:26

+ Get-VMHost $serverlist | Get-VM

+                          ~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-VM], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM

I thought "new version of VC, so maybe a new version of PowerCLI is needed"

PowerCLI v10 is available but, the only prerequisite, PowerShell Core 6 needs to be installed.

No big deal, right ?

Wrong !

PowerShell Core 6 no longer uses the ISE.

Microsoft are recommending the VS Code instead.

I've installed the VS Code App, PowerShell extensions and, installed PowerCLI using Install-Module -Name VMware.PowerCLI -Scope AllUsers

VS Code, doesn't appear to have tab completion, connect-viserv + TAB doesn't return Connect-VIserver for example.

Am I missing something here or, do I need to use something other than VS Code to replace the ISE when using PowerCLI 10 ?

Thanks

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

I'm on a Win10 box with PowerShell 5.1, and the Tab-completion works for me in the editor as well.

But does the VSCode realise that it is a PowerShell script?

You should create or save the file with a .ps1 extension, then PowerShell/PowerCLI tab-completeion should work.

Your modules look alright, nothing obviously wrong there.


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

View solution in original post

0 Kudos
5 Replies
LucD
Leadership
Leadership
Jump to solution

You don't need PowerShell 6 for PowerCLI 10 on a Windows box, you can use PowerShell 5.*.

Are you on a Windows box?

VSCode does have Tab-completion, it could be that you have to wait a few seconds before it actually works.

But for me Tab-completion works.

If you are more comfortable with the ISE, go for PowerShell 5.1 and use the ISE.

What do you currently have installed. Do a

Get-Module -Name VMware* -ListAvailable | Select Name,Version


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

0 Kudos
piercj2
Enthusiast
Enthusiast
Jump to solution

Thanks Luc,

I am using Windows Server 2016

I should have been more specific, from the Terminal window within VS Code, Tab Completion (color coding, etc...) works.

From the "File" window within VSC, it just appears to function as a basic text editor.

Here's what's installed

PS C:\> Get-Module -Name VMware* -ListAvailable | select name,version

Name                                Version

----                                -------

VMware.DeployAutomation             6.7.0.8250345

VMware.ImageBuilder                 6.7.0.8250345

VMware.PowerCLI                     10.1.1.8827524

VMware.Vim                          6.7.0.8343295

VMware.VimAutomation.Cis.Core       10.1.0.8377811

VMware.VimAutomation.Cloud          10.0.0.7893901

VMware.VimAutomation.Common         10.1.0.8342134

VMware.VimAutomation.Core           10.1.0.8344055

VMware.VimAutomation.HA             6.5.4.7567193

VMware.VimAutomation.HorizonView    7.5.0.8827468

VMware.VimAutomation.License        10.0.0.7893904

VMware.VimAutomation.Nsxt           10.1.0.8346947

VMware.VimAutomation.PCloud         10.0.0.7893924

VMware.VimAutomation.Sdk            10.1.0.8342078

VMware.VimAutomation.Srm            10.0.0.7893900

VMware.VimAutomation.Storage        10.1.0.8313015

VMware.VimAutomation.StorageUtility 1.2.0.0

VMware.VimAutomation.Vds            10.1.0.8344219

VMware.VimAutomation.Vmc            10.0.0.7893902

VMware.VimAutomation.vROps          10.0.0.7893921

VMware.VumAutomation                6.5.1.7862888

Regards,

Jason

0 Kudos
LucD
Leadership
Leadership
Jump to solution

I'm on a Win10 box with PowerShell 5.1, and the Tab-completion works for me in the editor as well.

But does the VSCode realise that it is a PowerShell script?

You should create or save the file with a .ps1 extension, then PowerShell/PowerCLI tab-completeion should work.

Your modules look alright, nothing obviously wrong there.


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

0 Kudos
piercj2
Enthusiast
Enthusiast
Jump to solution

saving the file as .ps1 worked Luc, thanks.

Now Tab Completing, Color Coding, etc... works as expected

All I have to do now is learn how to use VS Code avter getting used to the ISE for so long Smiley Happy

thanks again,

Jason

0 Kudos
LucD
Leadership
Leadership
Jump to solution

It took me a couple of days, but now I wouldn't want to go back :smileygrin:


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

0 Kudos