<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>VSC Archives - LucD notes</title>
	<atom:link href="https://www.lucd.info/knowledge-base/category/kb-dives/vsc/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.lucd.info/knowledge-base/category/kb-dives/vsc/</link>
	<description>My PowerShell ramblings</description>
	<lastBuildDate>Thu, 12 Sep 2019 09:36:46 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.9</generator>

<image>
	<url>https://www.lucd.info/wp-content/uploads/2018/12/cropped-120px-Tibetan_Dharmacakra-32x32.png</url>
	<title>VSC Archives - LucD notes</title>
	<link>https://www.lucd.info/knowledge-base/category/kb-dives/vsc/</link>
	<width>32</width>
	<height>32</height>
</image> 
<atom:link rel="hub" href="https://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="https://pubsubhubbub.superfeedr.com"/><atom:link rel="hub" href="https://websubhub.com/hub"/>	<item>
		<title>VSC and PowerCLI&#8217;s VimInventory and VimDatastore providers.</title>
		<link>https://www.lucd.info/knowledge-base/vsc-and-powerclis-viminventory-and-vimdatastore-providers/</link>
					<comments>https://www.lucd.info/knowledge-base/vsc-and-powerclis-viminventory-and-vimdatastore-providers/#comments</comments>
		
		<dc:creator><![CDATA[LucD]]></dc:creator>
		<pubDate>Thu, 12 Sep 2019 08:38:56 +0000</pubDate>
				<guid isPermaLink="false">http://www.lucd.info/?post_type=epkb_post_type_1&#038;p=6427</guid>

					<description><![CDATA[Currently Visual Studio Code is the de facto preferred editor for PowerShell and [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>Currently <a href="https://code.visualstudio.com/" target="_blank" rel="noopener noreferrer">Visual Studio Code</a> is the de facto preferred editor for PowerShell and PowerCLI scripts.<br>But there is a tiny problem when you try to mount a datastore as a PSDrive in the PowerShell Integrated Console.</p>



<p>Due to the way PowerCLI is written, it is not possible to use the <strong>VimInventory</strong> and <strong>VimDatastore</strong> providers, that come with PowerCLI, from the PowerShell Integrated Console.</p>



<p>Note that this is the console that shows the following.</p>



<figure class="wp-block-image"><img fetchpriority="high" decoding="async" width="894" height="280" src="https://www.lucd.info/wp-content/uploads/2019/09/host.png" alt="" class="wp-image-6429" srcset="https://www.lucd.info/wp-content/uploads/2019/09/host.png 894w, https://www.lucd.info/wp-content/uploads/2019/09/host-300x94.png 300w, https://www.lucd.info/wp-content/uploads/2019/09/host-768x241.png 768w, https://www.lucd.info/wp-content/uploads/2019/09/host-720x226.png 720w" sizes="(max-width: 894px) 100vw, 894px" /></figure>



<p>You will see the following error when you try to set up a drive with one of these providers.</p>



<figure class="wp-block-image"><img decoding="async" width="952" height="157" src="https://www.lucd.info/wp-content/uploads/2019/09/psprovider.png" alt="" class="wp-image-6428" srcset="https://www.lucd.info/wp-content/uploads/2019/09/psprovider.png 952w, https://www.lucd.info/wp-content/uploads/2019/09/psprovider-300x49.png 300w, https://www.lucd.info/wp-content/uploads/2019/09/psprovider-768x127.png 768w, https://www.lucd.info/wp-content/uploads/2019/09/psprovider-720x119.png 720w" sizes="(max-width: 952px) 100vw, 952px" /></figure>



<p>This is a known problem and mentioned in <a href="https://github.com/PowerShell/PowerShellEditorServices/issues/543" target="_blank" rel="noopener noreferrer">PowerShell/PowerShellEditorServices Issue #543</a> and also in the VMTN thread <a href="https://communities.vmware.com/message/2853575#2853575" name="&amp;lpos=apps_scodevmw : 83">Microsoft Visual Studio Code (VS Code) can not access vi and vis, vmstore and vmstores. Get-PSDrive and New-PSDrive -PSProvider VimDatastore dont work as expected</a></p>



<p>A couple of workarounds are available:</p>



<ul class="wp-block-list"><li>Disable the PSScriptAnalyzer in VSC</li><li>Don&#8217;t hover over PowerCLI cmdlets in the editor.</li><li>Load the PowerCLI modules before hovering over a PowerCLI cmdlet in the editor</li></ul>



<p>Of course, the preferred solution is option 3 from that list. And since VSC has it&#8217;s own profile, it is quite easy to implement.</p>



<p>Create/modify the VSC PowerShell profile, with</p>



<pre class="wp-block-code"><code>notepad $profile</code></pre>



<p>In the profile file, add the following line</p>



<pre class="wp-block-code"><code>Import-Module -Name VMware.PowerCLI 6> $null</code></pre>



<p>The redirection of <strong>stream 6</strong> is intended to suppress the <strong>Write-Host</strong> output from loading the VMware.PowerCLI module. This will only work in <strong>PowerShell v5</strong>, and higher.</p>



<p>If you find the output produced by loading the VMware.PowerCLI module annoying, there is a <a href="https://powercli.ideas.aha.io/ideas/PCLI-I-164" target="_blank" rel="noreferrer noopener" aria-label="PowerCLI Idea (opens in a new tab)">PowerCLI Idea</a> that asks to suppress this &#8220;feature&#8221;. Please upvote the issue if you also would like to see this removed.</p>


]]></content:encoded>
					
					<wfw:commentRss>https://www.lucd.info/knowledge-base/vsc-and-powerclis-viminventory-and-vimdatastore-providers/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
