<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>LucD notes</title>
	
	<link>http://www.lucd.info</link>
	<description>My PowerShell ramblings</description>
	<lastBuildDate>Tue, 07 Sep 2010 22:40:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/LucdNotes" /><feedburner:info uri="lucdnotes" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Taking the new Onyx 2.0 for a spin</title>
		<link>http://feedproxy.google.com/~r/LucdNotes/~3/25gZk2iiVRE/</link>
		<comments>http://www.lucd.info/2010/09/06/taking-the-new-onyx-2-0-for-a-spin/#comments</comments>
		<pubDate>Mon, 06 Sep 2010 21:45:59 +0000</pubDate>
		<dc:creator>LucD</dc:creator>
				<category><![CDATA[Onyx]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[vSphere]]></category>
		<category><![CDATA[SDK]]></category>

		<guid isPermaLink="false">http://www.lucd.info/?p=2629</guid>
		<description><![CDATA[One of the announcements during VMworld 2010 in San Francisco that perhaps got a bit obscured by the other &#8220;big&#8221; announcements, was the release of Onyx 2.0. For those of you that hadn&#8217;t heard of Project Onyx before, this nifty little tool captures all SOAP traffic that is passed between your vSphere client or PowerCLI [...]]]></description>
			<content:encoded><![CDATA[<p>One of the announcements during <a href="http://www.vmworld.com/community/conferences/2010/" target="_blank">VMworld 2010 in San Francisco</a> that perhaps got a bit obscured by the other &#8220;big&#8221; announcements, was the release of <a href="http://communities.vmware.com/community/vmtn/vsphere/automationtools/onyx?view=overview" target="_blank">Onyx 2.0</a>. For those of you that hadn&#8217;t heard of <strong>Project Onyx</strong> before, this nifty little tool captures all <strong>SOAP traffic</strong> that is passed between your vSphere client or PowerCLI session and the vCenter or ESX(i) server to which you are connected.</p>
<p style="text-align: left; padding-left: 210px;"><a href="http://lucd.info/wp-content/uploads/2010/09/onyx-icon1.gif"><img class="alignnone size-full wp-image-2636" title="onyx-icon" src="http://lucd.info/wp-content/uploads/2010/09/onyx-icon1.gif" alt="" width="62" height="55" /></a></p>
<p>And that&#8217;s not all, the Onyx program will <strong>translate</strong> the captured SOAP traffic into <strong>PowerShell code</strong>. This allows you to see which vSphere APIs are used and how parameter objects for these methods are constructed.</p>
<span id="What8217s_new_"><h2><span id="more-2629"></span>What&#8217;s new ?</h2></span>
<p>The new <a href="http://communities.vmware.com/community/vmtn/vsphere/automationtools/onyx?view=overview" target="_blank">Onyx 2.0</a> has a lot of new features and several improvements for older features.</p>
<ul>
<li>The most eye-catching new feature is that <a href="http://communities.vmware.com/community/vmtn/vsphere/automationtools/onyx?view=overview" target="_blank">Onyx 2.0</a> now also can, besides <strong>PowerShell</strong> code, produce <strong>SOAP</strong>, <strong>C#</strong> and <strong>JavaScript</strong> code. This should make life of the SDK developers and vOrchestrator users a lot easier!</li>
</ul>
<ul>
<li><a href="http://communities.vmware.com/community/vmtn/vsphere/automationtools/onyx?view=overview" target="_blank">Onyx 2.0</a> supports <strong>vSphere 4.1</strong>! In other words all new APIs, that were introduced with vSphere 4.1, are captured and shown correctly in the produced output.</li>
</ul>
<ul>
<li>A simple, but very user-friendly, feature is that <a href="http://communities.vmware.com/community/vmtn/vsphere/automationtools/onyx?view=overview" target="_blank">Onyx 2.0</a> allows you start the <strong>vSphere client</strong> or <strong>PowerCLI session</strong> directly from the Onyx Gui.</li>
</ul>
<ul>
<li>The vSphere client makes a lot of obvious API calls which are probably not important for the action you&#8217;re trying to capture. A good example is the continous use of PropertyCollector calls to refresh the values on the vSphere client screens. If you don&#8217;t want to obfuscate the resulting script with these calls, it&#8217;s now quite easy to suppress them. From the Onyx Gui you open the Settings menu and specify which <strong>methods</strong> should be<strong> ignored</strong>.</li>
</ul>
<span id="Sample_session"><h2>Sample session</h2></span>
<p>Using Onyx is quite <strong>simple</strong>!</p>
<p>Unfortunately the instructions on the <a href="http://labs.vmware.com/flings/onyx#" target="_blank">VMware LABS Onyx page</a> still seems to contain the <strong>Onyx 1.0</strong> instructions.And although they are still valid, the usage of Onyx became a lot easier.</p>
<p>When you start the program you are presented with the main screen.</p>
<p>Top-left in the toolbar you find the <strong>Connect</strong> button that allows you to set up the connection to the vCenter or ESX(i) server for which you want to capture the actions.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/09/onyx-1.png"><img class="alignnone size-full wp-image-2639" title="onyx-1" src="http://lucd.info/wp-content/uploads/2010/09/onyx-1.png" alt="" width="417" height="277" /></a></p>
<p>There is also a <strong>History</strong> option (the list box) that allows you to choose, by default, from your <strong>last 10</strong> connections.</p>
<p>The next window will ask you to which <strong>vCenter</strong> or <strong>ESX(i)</strong> server you want to connect.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/09/onyx-2.png"><img class="alignnone size-full wp-image-2641" title="onyx-2" src="http://lucd.info/wp-content/uploads/2010/09/onyx-2.png" alt="" width="246" height="195" /></a></p>
<p>With a <strong>new</strong> connection, you also have the option to automatically start the <strong>vSphere client</strong> or the <strong>PowerCLI client</strong>. Just enter your credentials and Onyx will take care of starting the client and setting up the connection.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/09/onyx-3.png"><img class="alignnone size-full wp-image-2640" title="onyx-3" src="http://lucd.info/wp-content/uploads/2010/09/onyx-3.png" alt="" width="244" height="298" /></a></p>
<p>And now the fun begins!</p>
<p>To start translating all your actions in the client into PowerShell code you hit the <strong>Start</strong> button in the toolbar.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/09/onyx-4.png"><img class="alignnone size-full wp-image-2643" title="onyx-4" src="http://lucd.info/wp-content/uploads/2010/09/onyx-4.png" alt="" width="476" height="45" /></a></p>
<p>Let&#8217;s have a look at a simple example. We&#8217;ll <strong>add 1 vCPU</strong> and <strong>a NIC</strong> to a <strong>guest</strong> in the vSphere client.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/09/onyx-6.png"><img class="alignnone size-full wp-image-2644" title="onyx-6" src="http://lucd.info/wp-content/uploads/2010/09/onyx-6.png" alt="" width="413" height="222" /></a></p>
<p>We immediately see the PowerShell code the Onyx program generated. Small remark, the colours in the output were done by me to better show the different parts of the generated code !</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/09/onyx-7.png"><img class="alignnone size-full wp-image-2645" title="onyx-7" src="http://lucd.info/wp-content/uploads/2010/09/onyx-7.png" alt="" width="414" height="268" /></a></p>
<p>With the help of the <a href="http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/index.html" target="_blank">SDK Reference</a> it is now quite easy to find back what each part of the generated code is doing.</p>
<p>The action we did in the vSphere client obviously uses the <a href="http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.VirtualMachine.html#reconfigure" target="_blank">ReconfigVM_Task</a> method which requires one parameter, a <a href="http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.vm.ConfigSpec.html" target="_blank">VirtualMachineConfigSpec</a>. In this <a href="http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.vm.ConfigSpec.html" target="_blank">VirtualMachineConfigSpec</a> there is the <strong>numCPUs</strong> property that permits the caller to define the number of <strong>vCPUs</strong>. And additionally there is the <a href="http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.vm.device.VirtualDeviceSpec.html" target="_blank">VirtualDeviceConfigSpec</a> object that takes care of the <strong>virtual HW</strong>, in this case the <strong>new NIC</strong>.</p>
<p>Notice how the object type that is entered in the <strong>device</strong> property, depends on the type of HW that was chosen. In this case the <strong>new NIC</strong> was specified as a <strong>vmxnet3</strong> type card.</p>
<p>Also note that the generated code uses the actual <strong>MoRef</strong> to get the <a href="http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.VirtualMachine.html" target="_blank">VirtualMachine</a> object. This is not considered good coding practice. So if you are going to use the generated code, make sure you fetch the guest based on it&#8217;s <strong>name</strong>. Something like this:</p>
<pre class="brush: powershell;">

...

$_this = Get-VM -Name &quot;PC1&quot; | Get-View

$_this.ReconfigVM_Task($spec)
</pre>
<p>One of the exciting new features in Onyx 2.0 is its ability to generate <strong>different types of output</strong>.</p>
<p>There is the <strong>raw SOAP</strong>.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/09/onyx-8.png"><img class="alignnone size-full wp-image-2647" title="onyx-8" src="http://lucd.info/wp-content/uploads/2010/09/onyx-8.png" alt="" width="416" height="353" /></a></p>
<p>And there is <strong>C#</strong>, which SDK developers will surely appreciate.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/09/onyx-9.png"><img class="alignnone size-full wp-image-2648" title="onyx-9" src="http://lucd.info/wp-content/uploads/2010/09/onyx-9.png" alt="" width="414" height="318" /></a></p>
<p>And there is <strong>JavaScript</strong> that can be used with <strong>vOrchestrator</strong>.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/09/onyx-10.png"><img class="alignnone size-full wp-image-2649" title="onyx-10" src="http://lucd.info/wp-content/uploads/2010/09/onyx-10.png" alt="" width="416" height="263" /></a></p>
<p>What is also a definite improvement compared to Onyx 1.0, is the fact most of the settings are now accessible via the <strong>Settings</strong> button in the toolbar.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/09/onyx-11.png"><img class="alignnone size-full wp-image-2650" title="onyx-11" src="http://lucd.info/wp-content/uploads/2010/09/onyx-11.png" alt="" width="539" height="46" /></a></p>
<p>There are two settings that I particularly like.</p>
<p>One is the option were you can easily specify which of the <strong>methods shall be ignored</strong> by Onyx. In other words which of the methods you don&#8217;t want to see in the generated output.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/09/onyx-12.png"><img class="alignnone size-full wp-image-2652" title="onyx-12" src="http://lucd.info/wp-content/uploads/2010/09/onyx-12.png" alt="" width="345" height="227" /></a></p>
<p>The other one is the <strong>obfuscation</strong> feature. This allows you to suppress <strong>sensitive information</strong> from the generated output and/or the log.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/09/onyx-13.png"><img class="alignnone size-full wp-image-2651" title="onyx-13" src="http://lucd.info/wp-content/uploads/2010/09/onyx-13.png" alt="" width="346" height="226" /></a></p>
<span id="Room_for_improvement"><h2>Room for improvement</h2></span>
<p>The new <a href="http://communities.vmware.com/community/vmtn/vsphere/automationtools/onyx?view=overview" target="_blank">Onyx 2.0</a> definitely is a more user-friendly and robust application than it&#8217;s predecessor. But while using the product there are some features that seem to be missing or that would make the product even better.<br />
What follows is a &#8220;<em>personal</em>&#8221; list of notes I took while test driving the product.</p>
<ul>
<li>&#8220;Start a new Connection&#8221; has a &#8220;Launch Client when connected&#8221; option, which is great! But the <strong>Username</strong> and <strong>Password</strong> have to be entered each time. It would have been handy if there was something like the &#8220;<strong>Use Windows session credentials</strong>&#8221; option like the vSphere client has.</li>
</ul>
<ul>
<li>The Connect button in the Onyx toolbar has a &#8220;<strong>History</strong>&#8221; option where you can chose any of the previous connections you made in the past. Unfortunately the &#8220;History&#8221; doesn&#8217;t keep track of the <strong>client</strong> with which you connected, neither does it allow you to specify a client to connect.</li>
</ul>
<ul>
<li>The Connection history is kept in the <strong>Onyx.settings</strong> file, which is in fact an XML file. When you want to remove one of these old connections, you will have to <strong>edit</strong> the Onyx.settings file. It would have been handy to have this option available under the <strong>Settings option</strong>.</li>
</ul>
<ul>
<li>The &#8220;Launch Client when connected&#8221; option is a great new feature. It would have been useful if it allowed the user, in the Settings perhaps, to add <strong>additional clients</strong>. I&#8217;m thinking of the PowerGui, vEcoShell, PowerShellPlus&#8230; users.</li>
<li>The raw SOAP output only shows the <strong>request packets</strong>, not the <strong>reply packets</strong>. From the <strong>log</strong> it is obvious that this information is available. Perhaps it could be a useful feature to allow for the selection of the reply packet in the raw SOAP output.</li>
</ul>
<span id="Conclusion."><h2>Conclusion.</h2></span>
<p>Don&#8217;t let it be misunderstood, <a href="http://communities.vmware.com/community/vmtn/vsphere/automationtools/onyx?view=overview" target="_blank">Onyx 2.0</a> is a product that you need when you take automation through PowerCLI serious. A product that you should <strong>know</strong> and <strong>use</strong> in your vSphere environment.</p>
<ul>
<li>It will help you understand what goes on <strong>under the hood</strong>.</li>
</ul>
<ul>
<li>It will make it easier to <strong>find</strong> which <strong>methods and objects</strong> to use for those functions that are not yet covered by a PowerCLI cmdlet.</li>
</ul>
<p>Download <a href="http://communities.vmware.com/community/vmtn/vsphere/automationtools/onyx?view=overview" target="_blank">Onyx 2.0</a> and start playing!</p>
<img src="http://feeds.feedburner.com/~r/LucdNotes/~4/25gZk2iiVRE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lucd.info/2010/09/06/taking-the-new-onyx-2-0-for-a-spin/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.lucd.info/2010/09/06/taking-the-new-onyx-2-0-for-a-spin/</feedburner:origLink></item>
		<item>
		<title>Using the ThinApp SDK from PowerShell</title>
		<link>http://feedproxy.google.com/~r/LucdNotes/~3/r4oHhz9Fy6A/</link>
		<comments>http://www.lucd.info/2010/08/21/using-the-thinapp-sdk-from-powershell/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 23:18:10 +0000</pubDate>
		<dc:creator>LucD</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SDK]]></category>
		<category><![CDATA[ThinApp]]></category>

		<guid isPermaLink="false">http://www.lucd.info/?p=2602</guid>
		<description><![CDATA[On August 19th 2010 the long awaited ThinApp SDK became available.It allows you to programmatically interact with your ThinApp packages.  The SDK package is foreseen to be used with Visual Studio, as can be deduced from the  included merge module called ThinAppSDK.msm. The samples that come with the SDK unfortunately only show the use of [...]]]></description>
			<content:encoded><![CDATA[<p>On <strong>August 19th 2010</strong> the long awaited <a href="http://communities.vmware.com/community/developer/forums/thinapp?view=discussions" target="_blank">ThinApp SDK</a> became available.It allows you to programmatically interact with your ThinApp packages.  The SDK package is foreseen to be used with Visual Studio, as can be deduced from the  included merge module called <strong>ThinAppSDK.msm</strong>. The samples that come with the SDK unfortunately only show the use of the SDK with <strong>C++</strong> and <strong>VBScript</strong>. But with a bit of fiddling it&#8217;s quite easy to use the APIs from your PowerShell environment.</p>
<p>This post will show you:</p>
<ul>
<li>how to set up the SDK for use from PowerShell</li>
<li>some usage examples from PowerShell.</li>
</ul>
<p><span id="more-2602"></span></p>
<span id="Prepare_the_environment"><h2>Prepare the environment</h2></span>
<p>The SDK package doesn&#8217;t contain a DLL with a manifest so we can&#8217;t use the <a href="http://msdn.microsoft.com/en-us/library/system.reflection.assembly.loadfile.aspx" target="_blank">LoadFile</a> method to load the DLL into memory. But the ThinApp SDK has foreseen this.</p>
<p>First make sure you have the <strong>ThinAppSDK.dll</strong> and <strong>ThinAppSDKSrvr.exe</strong> files together in a directory.</p>
<p>Then register the DLL with the <a href="http://msdn.microsoft.com/en-us/library/ms859484.aspx" target="_blank"><strong>regsvr32</strong></a> command. On a Windows client that has <strong>UAC</strong> enabled make sure you run regsvr32 from an <strong>elevated command prompt</strong> (run as administrator) !</p>
<p><strong><a href="http://lucd.info/wp-content/uploads/2010/08/ThinApp-SDK-CMD1.png"><img class="alignnone size-full wp-image-2622" title="ThinApp-SDK-CMD" src="http://lucd.info/wp-content/uploads/2010/08/ThinApp-SDK-CMD1.png" alt="" width="591" height="143" /></a><br />
</strong></p>
<p>Thanks to <strong>Greg Geldorp</strong>, the <strong>VMware Engineer</strong> that owns the <strong>ThinApp SDK</strong>, we know how the DLL gets loaded on a 64-bit client.</p>
<p>I quote from his reply in <a href="http://communities.vmware.com/message/1595611#1595611" target="_blank">this thread</a>.</p>
<p><em>&#8220;ThinAppSDK.dll is the DLL  that implements the ThinApp SDK objects like ThinApp.Management. It is a  32-bit DLL, if you create a ThinApp.Management object from a 32-bit  process Windows will load ThinAppSDK.dll into that process (if the DLL  was registered correctly with regsvr32). However, it&#8217;s not possible to  load a 32-bit DLL into a 64-bit process. So if you try to create a  ThinApp.Management object from a 64-bit process, ThinAppSDK.dll cannot  be loaded directly into that process.<br />
That&#8217;s where ThinAppSDKSrvr.exe comes in. Windows will detect this  situation and will automatically launch ThinAppSDKSrvr.exe. Since  ThinAppSDKSrvr.exe is a 32-bit application, it can load ThinAppSDK.dll  just fine. Windows will then &#8220;forward&#8221; ThinApp SDK calls (e.g. the  GetThinAppType method call) from the 64-bit process to  ThinAppSDKSrvr.exe, which will in turn forward it to ThinAppSDK.dll. The  result will be passed back from ThinAppSDK.dll to ThinAppSDKSrvr.exe  via Windows to the 64-bit application.&#8221;</em></p>
<p>You can always verify, for example with <a href="http://support.microsoft.com/kb/308549" target="_blank">MSInfo32</a>, that the DLL has been loaded.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/08/SDK-DLL-loaded.png"><img class="alignnone size-full wp-image-2604" title="SDK-DLL-loaded" src="http://lucd.info/wp-content/uploads/2010/08/SDK-DLL-loaded.png" alt="" width="427" height="246" /></a></p>
<p>What follows was tested on <strong>Windows XP Pro Sp3 32-bit</strong> and on <strong>Windows 7 64-bit</strong>.</p>
<span id="How_to_use_the_SDK"><h2>How to use the SDK</h2></span>
<span id="First_steps"><h3>First steps</h3></span>
<p>All the following examples are based on a ThinApped version I made of <a href="http://www.wmhelp.com/xmlpad3.htm" target="_blank">XmlPad3</a>, my favorite &#8216;free&#8217; XML editor.</p>
<p>Let&#8217;s start with something simple.</p>
<p>The following lines will take an EXE produced by the ThinApp build process and determine the ThinApp type of file.</p>
<pre class="brush: powershell;">
$sampleApp = &quot;C:\ThinApp\XmlPad3\bin\XmlPad.exe&quot;

$thinMgmt = New-Object -ComObject ThinApp.Management
$thinMgmt.GetThinAppType($sampleApp)
</pre>
<p>The result of the this simple script is not world-shocking but at least it show that we can interact with the ThinApp package.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/08/ThinApp-SDK-script-1.png"><img class="alignnone size-full wp-image-2608" title="ThinApp-SDK-script-1" src="http://lucd.info/wp-content/uploads/2010/08/ThinApp-SDK-script-1.png" alt="" width="448" height="209" /></a></p>
<p>From the <strong>VMware ThinApp SDK API Reference Guide</strong>, that is part of the SDK, we learn that this file is the main data container.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/08/ThinApp-SDK-type.png"><img class="alignnone size-full wp-image-2609" title="ThinApp-SDK-type" src="http://lucd.info/wp-content/uploads/2010/08/ThinApp-SDK-type.png" alt="" width="385" height="206" /></a></p>
<p>Let&#8217;s take another entry point of the package. In this case the cmd.exe entry point.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/08/ThinApp-SDK-script-2.png"><img class="alignnone size-full wp-image-2610" title="ThinApp-SDK-script-2" src="http://lucd.info/wp-content/uploads/2010/08/ThinApp-SDK-script-2.png" alt="" width="438" height="194" /></a></p>
<p>And we learn that this is a shortcut, or entry point, but not a container.</p>
<span id="A_bit_more_advanced_script"><h3>A bit more advanced script</h3></span>
<p>Time to move on to a somewhat more advanced script.</p>
<p>With the SDK there are 2 samples and one of these is a script that lists subfolders and files for a specific path in the package.</p>
<p>This script is a loose emulation of the original.</p>
<pre class="brush: powershell;">
$sampleApp = &quot;C:\ThinApp\XmlPad3\bin\XmlPad.exe&quot;
$target = &quot;%ProgramFilesDir%\WMHelp Software\WMHelp XmlPad&quot;

$thinMgmt = New-Object -ComObject ThinApp.Management
$package = $thinMgmt.OpenPackage($sampleApp)
$vfs = $package.GetVFileSystemObject($null)
$subFolderCount = 0
$fileCount = 0
$totalFileSize = 0
if($vfs.FolderExists($target)){
    $folder = $vfs.GetFolder($target)
    Write-Host &quot;Directory of&quot; $sampleApp &quot;|&quot; $target
    $subFolderCount = $folder.SubFolders.Count
    $folder.SubFolders | %{
        Write-Host $_.DateLastModified &quot;&lt;DIR&gt;&quot; $_.Size $_.Name
    }
    $fileCount = $folder.Files.Count
    $folder.Files | %{
        $totalFileSize += $_.Size
        Write-Host $_.DateLastModified &quot;     &quot; $_.Size $_.Name
    }
}
elseif($vfs.FileExists($target)){
    $file = $vfs.GetFile($target)
    Write-Host &quot;Directory of&quot; $sampleApp &quot;|&quot; $file.Path
    $fileCOunt = 1
    $totalFileSize += $file.Size
    Write-Host $file.DateLastModified &quot;     &quot; $file.Size $file.Name
}
else{
    Write-Host &quot;Directory of&quot; $sampleApp
    Write-Host &quot;File not found&quot;
}
Write-Host $fileCount &quot;File(s)&quot; $totalFileSize &quot;bytes&quot;
Write-Host $subFolderCount &quot;Dir(s)&quot;
</pre>
<p>A run of this script produces something like this:</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/08/ThinApp-SDK-script-3.png"><img class="alignnone size-full wp-image-2614" title="ThinApp-SDK-script-3" src="http://lucd.info/wp-content/uploads/2010/08/ThinApp-SDK-script-3.png" alt="" width="741" height="416" /></a></p>
<span id="Conclusion"><h2>Conclusion</h2></span>
<p>The <strong>ThinApp SDK</strong> offers even for the PowerShell adept easy access to his ThinApp packages.  Another small step towards the complete automation of your &#8216;virtual&#8217; environment.</p>
<img src="http://feeds.feedburner.com/~r/LucdNotes/~4/r4oHhz9Fy6A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lucd.info/2010/08/21/using-the-thinapp-sdk-from-powershell/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.lucd.info/2010/08/21/using-the-thinapp-sdk-from-powershell/</feedburner:origLink></item>
		<item>
		<title>On parents and nested properties</title>
		<link>http://feedproxy.google.com/~r/LucdNotes/~3/ipegBk9lgPg/</link>
		<comments>http://www.lucd.info/2010/08/01/on-parents-and-nested-properties/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 19:52:20 +0000</pubDate>
		<dc:creator>LucD</dc:creator>
				<category><![CDATA[New-VIProperty]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.lucd.info/?p=2569</guid>
		<description><![CDATA[In a recent post on the vSphere PowerCLI Blog, called New Nested Properties for Navigating to Parent Objects in PowerCLI 4.1, some new features were introduced. In PowerCLI 4.1 some objects now have, besides the ParentId property, the actual parent object itself. This will take quite some complexity out of several scripts. This is definitely [...]]]></description>
			<content:encoded><![CDATA[<p>In a recent post on the <a href="http://blogs.vmware.com/vipowershell/" target="_blank">vSphere PowerCLI Blog</a>, called <a href="http://blogs.vmware.com/vipowershell/2010/07/new-nested-properties-for-navigating-to-associated-objects-in-powercli-41.html" target="_blank">New Nested Properties for Navigating to Parent Objects in PowerCLI 4.1</a>, some new features were introduced.</p>
<p>In <strong>PowerCLI 4.1</strong> some objects now have, besides the <strong>ParentId</strong> property, the <strong>actual parent object</strong> itself. This will take quite some complexity out of several scripts. This is definitely a good improvement.</p>
<p>The 2nd novelty in that post were <strong>nested properties</strong>. Some <strong>SDK object</strong> properties are now mapped directly in the <strong>PowerCLI object</strong>. For example the <strong>VMHost </strong>object now holds the <strong>StorageInfo</strong> and <strong>NetworkInfo</strong> properties besides some others. And what is even better, there is hardly any performance impact since the values will only be loaded the first time you access the properties (similar to the <strong>ExtensionData</strong> property).</p>
<p><span id="more-2569"></span></p>
<p>The selection of the SDK properties that are available this way were made by the <strong>PowerCLI Dev Team</strong> and are probably based on the most commonly used SDK object properties. But what if you want another property of the SDK object in your script ?</p>
<p>You can of course access all the properties of the SDK object through the <strong>ExtensionData</strong> property. But that comes with a performance penalty and will be visible when you run your script against a  larger vSphere environment.</p>
<p>Luckily <strong>PowerCLI 4.1</strong> also introduced the <a href="http://www.vmware.com/support/developer/PowerCLI/PowerCLI41/html/New-VIProperty.html" target="_blank">New-VIProperty</a> cmdlet.</p>
<p>With that cmdlet it&#8217;s quite simple to map your selection of SDK object properties into the PowerCLI object.</p>
<p>Suppose you want to see/check the ESX(i) host&#8217;s <strong>hardware</strong> in a script. Then you can just add this line</p>
<pre class="brush: powershell;">
New-VIProperty -Name 'Hardware' -ObjectType 'VMHost' `
	-ValueFromExtensionProperty 'Hardware' -Force
</pre>
<p>And bingo, each object returned by Get-VMHost will now have a Hardware property.</p>
<p>Another example is the <strong><em>yellow</em></strong> folder to which a <strong>VirtualMachine</strong> belongs. In the PowerCLI object for a <strong>VirtualMachine</strong> you have a <strong>Folder</strong> property, but that points to the <strong><em>blue</em></strong> folder in which a guest is located.</p>
<p>Again the <a href="http://www.vmware.com/support/developer/PowerCLI/PowerCLI41/html/New-VIProperty.html" target="_blank">New-VIProperty</a> comes to the rescue.</p>
<pre class="brush: powershell;">
New-VIProperty -Name 'YellowFolderName' -ObjectType 'VirtualMachine' -Value {
	param($vm)

	$entity = Get-View $vm.ExtensionData.ResourcePool
	while($entity.GetType().Name -ne 'Folder'){
		$entity = Get-View $entity.Parent
	}
	$entity.Name
} -Force -BasedOnExtensionProperty 'ResourcePool'
</pre>
<p>Heck, you can even use a recursive function. Like this:</p>
<pre class="brush: powershell;">
New-VIProperty -Name 'YellowFolderName' -ObjectType 'VirtualMachine' -Value {
	param($vm)

	function Get-FirstFolder{
		param($entityMoRef)

		$entity = Get-View $entityMoRef
		while($entity.GetType().Name -ne 'Folder'){
			$entity = Get-FirstFolder $entity.Parent
		}
		$entity
	}

	(Get-FirstFolder $vm.ExtensionData.ResourcePool).Name
} -Force
</pre>
<p>Don&#8217;t know how you feel, but I&#8217;m convinced of the power of the <a href="http://www.vmware.com/support/developer/PowerCLI/PowerCLI41/html/New-VIProperty.html" target="_blank">New-VIProperty</a> cmdlet  <img src='http://lucd.info/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<span id="Some_personal_reflections"><h3>Some personal reflections</h3></span>
<p>With the power of the <a href="http://www.vmware.com/support/developer/PowerCLI/PowerCLI41/html/New-VIProperty.html" target="_blank">New-VIProperty</a> cmdlet I feel that these extra properties, that <strong>PowerCLI 4.1</strong> introduces, should have been optional or even left out by default. I know there is hardly any performance impact involved, but on the other hand they don&#8217;t make it easier for a PowerCLI newbie to grasp what is there.</p>
<p>What do you think ?</p>
<img src="http://feeds.feedburner.com/~r/LucdNotes/~4/ipegBk9lgPg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lucd.info/2010/08/01/on-parents-and-nested-properties/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.lucd.info/2010/08/01/on-parents-and-nested-properties/</feedburner:origLink></item>
		<item>
		<title>PowerCLI Book Update</title>
		<link>http://feedproxy.google.com/~r/LucdNotes/~3/_jT_X30i5ic/</link>
		<comments>http://www.lucd.info/2010/07/26/powercli-book-update/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 18:28:19 +0000</pubDate>
		<dc:creator>LucD</dc:creator>
				<category><![CDATA[Book]]></category>
		<category><![CDATA[PowerCLI]]></category>

		<guid isPermaLink="false">http://www.lucd.info/?p=2521</guid>
		<description><![CDATA[As we announced in our post &#8220;We&#8217;re writing a book!&#8220;, Alan and myself started writing a PowerCLI book. At about the same time Alan got the once-in-a-lifetime oppurtunity to join EMC as a vSpecialist. Now you don&#8217;t become a vSpecialist for free! Alan has been spending a fair amount of time in training, coming up to [...]]]></description>
			<content:encoded><![CDATA[<p>As we announced in our post &#8220;<a href="http://www.lucd.info/2010/05/04/were-writing-a-book/" target="_blank">We&#8217;re writing a book!</a>&#8220;, <a href="https://twitter.com/alanrenouf" target="_blank">Alan</a> and <a href="https://twitter.com/LucD22" target="_blank">myself</a> started writing a <strong>PowerCLI</strong> book.</p>
<p>At about the same time Alan got the <strong>once-in-a-lifetime</strong> oppurtunity to join EMC as a <strong>vSpecialist</strong>.</p>
<p>Now you don&#8217;t become a vSpecialist for free! Alan has been spending a fair amount of time in training, coming up to  speed with <strong>VCE</strong> (VMware/Cisco/EMC) and traveling all over the globe. The little time he was at home, went of course in the first place to his loved ones.</p>
<p>As a consequence, our chapter-writing schedule failed misserably.<br />
So we decided to get some extra help for the book in order to keep our deadline.</p>
<p>And now, for the proverbial &#8220;silver lining&#8221;, have a look who agreed to help us out:</p>
<table style="width: 576px; height: 44px;" border="0">
<tbody>
<tr style="text-align: center;">
<td><span style="font-size: medium;"><strong>Glenn Sizemore</strong></span></td>
<td><span style="font-size: medium;"><strong>Jonathan Medd</strong></span></td>
<td><span style="font-size: medium;"><strong>Arnim van Lieshout</strong></span></td>
</tr>
<tr style="text-align: center;">
<td style="text-align: left;">
<p style="text-align: center;"><span style="font-size: small;">Winner of the </span></p>
<p style="text-align: center;"><span style="font-size: small;">Scripting Games 2010</span></p>
<p style="text-align: center;"><span style="font-size: small;"> vExpert</span></p>
</td>
<td style="text-align: center;"><span style="font-size: medium;"><span style="font-size: small;">PowerShell MVP</span><strong><br />
</strong></span></td>
<td style="text-align: center;"><span style="font-size: medium;"><span style="font-size: small;">vExpert</span><strong><br />
</strong></span></td>
</tr>
<tr>
<td><a href="http://lucd.info/wp-content/uploads/2010/07/glenn.png"></a></p>
<p style="text-align: center;"><a href="http://lucd.info/wp-content/uploads/2010/07/glenn.png"><img class="alignnone size-full wp-image-2522" title="glenn" src="http://lucd.info/wp-content/uploads/2010/07/glenn.png" alt="" width="73" height="73" /></a></p>
</td>
<td style="text-align: center;"><a href="http://lucd.info/wp-content/uploads/2010/07/jonathan.png"><img class="alignnone size-full wp-image-2523" title="jonathan" src="http://lucd.info/wp-content/uploads/2010/07/jonathan.png" alt="" width="65" height="85" /></a></td>
<td style="text-align: center;"><a href="http://lucd.info/wp-content/uploads/2010/07/arnim.png"><img class="alignnone size-full wp-image-2524" title="arnim" src="http://lucd.info/wp-content/uploads/2010/07/arnim.png" alt="" width="86" height="93" /></a></td>
</tr>
</tbody>
</table>
<p>In other words, the book will now be written by &#8220;<strong>4 vExperts and a MVP</strong>&#8221; !</p>
<p>Can&#8217;t wait to read it  <img src='http://lucd.info/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<img src="http://feeds.feedburner.com/~r/LucdNotes/~4/_jT_X30i5ic" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lucd.info/2010/07/26/powercli-book-update/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.lucd.info/2010/07/26/powercli-book-update/</feedburner:origLink></item>
		<item>
		<title>Script vSphere 4.1 AD Authentication</title>
		<link>http://feedproxy.google.com/~r/LucdNotes/~3/KVFeBbubKMU/</link>
		<comments>http://www.lucd.info/2010/07/25/script-vsphere-4-1-ad-authentication/#comments</comments>
		<pubDate>Sun, 25 Jul 2010 15:20:54 +0000</pubDate>
		<dc:creator>LucD</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Authentication]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[vSphere]]></category>
		<category><![CDATA[SDK]]></category>

		<guid isPermaLink="false">http://www.lucd.info/?p=2499</guid>
		<description><![CDATA[One of the new features that came with vSphere 4.1 was the ability to use Active Directory Authentication on ESX(i) servers for permissions, console access and ssh access.This is a great feature that you will probably want to activate on all your ESX(i) servers. Unfortunately this new feature is not available in PowerCLI 4.1. That [...]]]></description>
			<content:encoded><![CDATA[<p>One of the new features that came with vSphere 4.1 was the ability to use <strong>Active Directory Authentication</strong> on ESX(i) servers for permissions, console access and ssh access.This is a great feature that you will probably want to activate on all your ESX(i) servers.</p>
<p>Unfortunately this new feature is not available in <a href="http://downloads.vmware.com/downloads/download.do?downloadGroup=SDKWIN41" target="_blank">PowerCLI 4.1</a>. That means you can&#8217;t set this up in your configuration scripts through a PowerCLI cmdlet. In most such cases you can fall back on one of the <a href="javascript:void(location.href='left-pane.html');%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20void(parent.frames[1].location.href='right-pane.html');" target="_blank">SDK APIs</a> to bypass this lack of a cmdlet. But unfortunately the new &#8220;managers&#8221;, of which <a href="http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.host.ActiveDirectoryAuthentication.html" target="_blank">HostActiveDirectoryAuthentication</a> is one, are not available in the VMware.Vim assembly either.</p>
<p><strong>Rob</strong> raised this in a recent <a href="http://communities.vmware.com/community/vmtn/vsphere/automationtools/powercli" target="_blank">PowerCLI Community</a> <a href="http://communities.vmware.com/message/1576319#1576319" target="_blank">thread</a>. <strong>Yasen</strong>, one of the PowerCLI Dev Team members, provided a bypass. To make this bypass a bit more accessible, I decided to roll it up in a PowerShell function.</p>
<p><span id="more-2499"></span></p>
<span id="A_little_bit_of_background_information"><h2>A (little) bit of background information</h2></span>
<p>The <strong>Active Directory Authentication</strong> feature has been discussed at length in several <strong>vSphere 4.1</strong> blog posts.</p>
<p>A great video, that explains what it is and how you can use it, was made by <a href="http://twitter.com/davidmdavis" target="_blank">David Davis</a>. See his <a href="http://www.vmwarevideos.com/video-new-vsphere-4-1-windows-active-directory-authentication" target="_blank">VIDEO: New vSphere 4.1 Windows Active Directory Authentication</a> post.</p>
<span id="The_script"><h2>The script</h2></span>
<pre class="brush: powershell;">
#requires -version 2

function Get-VMHostAuthentication{
&lt;#
.SYNOPSIS
	The function retrieves the authentication services from an ESX(i) host
.DESCRIPTION
	This function retrieves the configured authentication services from one
	or more ESX(i) hosts.
.NOTES
	Author: Luc Dekens
.PARAMETER VMHost
	Specify the ESX(i) host
.EXAMPLE
	PS&gt; Get-VMHost | Get-VMHostAuthentication
.EXAMPLE
	PS&gt; Get-VMHostAuthentication -VMHost (Get-VMHost)
#&gt;
	param(
	[parameter(ValueFromPipeline = $true,Position=1,Mandatory = $true)]
	[VMware.VimAutomation.ViCore.Impl.V1.Inventory.VMHostImpl[]]$VMHost)

	process{
		if(!$VMHost){$VMHost = $_}
		foreach($esx in $VMHost){
			$filter = New-Object VMware.Vim.PropertyFilterSpec -Property @{
				ObjectSet = New-Object VMware.Vim.ObjectSpec -Property @{
					Obj = $esx.ExtensionData.ConfigManager.AuthenticationManager
				}
				PropSet = New-Object VMware.Vim.PropertySpec -Property @{
					Type = &quot;HostAuthenticationManager&quot;
					All = $true
				}
			}
			$collector = Get-View $esx.ExtensionData.Client.ServiceContent.PropertyCollector
			$content = $collector.RetrieveProperties($filter)
			$stores = $content | Select -First 1 | %{$_.PropSet} | where {$_.Name -eq &quot;info&quot;}
			foreach($authConfig in $stores.Val.AuthConfig){
				$row = New-Object PSObject
				$row | Add-Member -MemberType NoteProperty -Name Name -Value $null
				$row | Add-Member -MemberType NoteProperty -Name Type -Value $null
				$row | Add-Member -MemberType NoteProperty -Name Enabled -Value $null
				$row | Add-Member -MemberType NoteProperty -Name Domain -Value $null
				$row | Add-Member -MemberType NoteProperty -Name Membership -Value $null
				$row | Add-Member -MemberType NoteProperty -Name Trust -Value $null
				$row.Name = $esx.Name
				$row.Enabled = $authConfig.Enabled
				switch($authConfig.GetType().Name){
					'HostLocalAuthenticationInfo'{
						$row.Type = 'Local authentication'
					}
					'HostActiveDirectoryInfo'{
						$row.Type = 'Active Directory'
						$row.Domain = $authConfig.JoinedDomain
						$row.Membership = $authConfig.DomainMembershipStatus
						$row.Trust = $authConfig.TrustedDomain
					}
				}
				$row
			}
		}
	}
}

function Set-VMHostADDomain{
&lt;#
.SYNOPSIS
	The function adds or removes an ESX(i) 4.1 server to/from an Active Directory domain
.DESCRIPTION
	By adding an ESX(i) 4.1 host to an AD domain, you can use AD authentication for console
	access, SSH and permissions on the host's child objects
.NOTES
	Author: Luc Dekens
.PARAMETER VMHost
	Specify the ESX(i) host
.PARAMETER Domain
	The name of the Active Directory domain in FQDN notation
.PARAMETER User
	An Active Directory account that administrative authority to add hosts to AD
.PARAMETER Password
	The password for the AD account specified in -User
.PARAMETER Credential
	The credentials for an AD account with administrative authority to add hosts to AD
.PARAMETER ADJoin
	A switch indicating if the host shall be added ($true) or removed ($false) from AD
.PARAMETER RemovePermission
	Will remove ($true) all AD permissions that still exist on the ESX(i) host and
	it's children
.EXAMPLE
	PS&gt; Get-VMHost | Set-VMHostADDomain -ADJoin:$true -Domain $domain -User $user -Password $pswd
.EXAMPLE
	PS&gt; Set-VMHostADDomain -VMHost (Get-VMHost) -ADJoin:$true -Credential $cred
.EXAMPLE
	PS&gt; Set-VMHostADDomain -VMHost (Get-VMHost) -ADJoin:$false -RemovePermission:$true
#&gt;
	param(
	[parameter(ValueFromPipeline = $true,Position=1,Mandatory = $true)]
	[VMware.VimAutomation.ViCore.Impl.V1.Inventory.VMHostImpl[]]$VMHost,
	[string]$Domain,
	[string]$User,
	[string]$Password,
	[System.Management.Automation.PSCredential]$Credential,
	[switch]$ADJoin,
	[switch]$RemovePermission = $false
	)

	process{
		if(!$VMHost){$VMHost = $_}
		foreach($esx in $VMHost){
			$filter = New-Object VMware.Vim.PropertyFilterSpec -Property @{
				ObjectSet = New-Object VMware.Vim.ObjectSpec -Property @{
					Obj = $esx.ExtensionData.ConfigManager.AuthenticationManager
				}
				PropSet = New-Object VMware.Vim.PropertySpec -Property @{
					Type = &quot;HostAuthenticationManager&quot;
					All = $true
				}
			}
			$collector = Get-View $esx.ExtensionData.Client.ServiceContent.PropertyCollector
			$content = $collector.RetrieveProperties($filter)
			$stores = $content | Select -First 1 | %{$_.PropSet} | where {$_.Name -eq &quot;supportedStore&quot;}
			$result = $stores.Val | where {$_.Type -eq &quot;HostActiveDirectoryAuthentication&quot;}
			$hostADAuth = [VMware.Vim.VIConvert]::ToVim41($result)

			if($ADJoin){
				if($Credential){
					$User = $Credential.GetNetworkCredential().UserName
					$Password = $Credential.GetNetworkCredential().Password
				}
				$taskMoRef = $esx.ExtensionData.Client.VimService.JoinDomain_Task($hostADAuth,$Domain,$User,$Password)
			}
			else{
				$taskMoRef = $esx.ExtensionData.Client.VimService.LeaveCurrentDomain_Task($hostADAuth,$RemovePermission)
			}
			$esx.ExtensionData.WaitForTask([VMware.Vim.VIConvert]::ToVim($taskMoRef))
		}
	}
}
</pre>
<span id="Annotations"><h4>Annotations</h4></span>
<p><strong>Line 1</strong>: This function uses PowerShell v2 features and will not run with PowerShell v1</p>
<p><strong>Line 3-63</strong>: The<strong> Get-VMHostAuthentication</strong> function</p>
<p><strong>Line 38-60</strong>: Return information for each of the configured authentication methods.</p>
<p><strong>Line 65-138</strong>: The <strong>Set-VMHostADDomain</strong> function</p>
<p><strong>Line 24,108</strong>: Handles use of the function in a pipeline or with a -VMHost parameter</p>
<p><strong>Line 26-34,110-118</strong>: Creates the <a href="http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vmodl.query.PropertyCollector.FilterSpec.html" target="_blank">PropertyFilterSpec</a> object through the use of the hash table property list.</p>
<p><strong>Line 119-123</strong>: The &#8216;bypass&#8217; from Yasen. It uses the <a href="http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vmodl.query.PropertyCollector.html" target="_blank">PropertyCollector</a> to  ultimately get at the MoRef of the <a href="http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.host.ActiveDirectoryAuthentication.html" target="_blank">HostActiveDirectoryAuthentication</a> manager.</p>
<p><strong>Line 123</strong>: The MoRef is converted to a VIM 4.1 MoRef with the <strong>ToVim41</strong> method of the builtin VIConvert class.</p>
<p><strong>Line 125</strong>: Depending on the state of the <strong>ADJoin</strong> switch, the host is &#8216;joined&#8217; or &#8216;removed&#8217; from the AD domain.</p>
<p><strong>Line 126-129</strong>: If the AD account is passed through a <a href="http://msdn.microsoft.com/en-us/library/system.management.automation.pscredential%28VS.85%29.aspx" target="_blank">PSCredential</a> object, the clear text account and password are extracted.</p>
<p><strong>Line 135</strong>: The script waits for the completion of the called method.</p>
<span id="Examples"><h2>Examples</h2></span>
<p>To display the authentication services for an ESX(i) server that has no AD authentication configured.</p>
<pre class="brush: powershell;">
Get-VMHost $esxName | Get-VMHostAuthetication
</pre>
<p>This returns the following information.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/07/auth-local-only.png"><img class="alignnone size-full wp-image-2512" title="auth-local-only" src="http://lucd.info/wp-content/uploads/2010/07/auth-local-only.png" alt="" width="583" height="75" /></a></p>
<p>To add a specific ESX(i) server to an Active Directory domain you can do</p>
<pre class="brush: powershell;">
Set-VMHostADDomain -VMhost (Get-VMHost $esxName) -ADJoin:$true -Domain 'test.local' -User 'Administrator' -Password 'MyPassword'
</pre>
<p>or</p>
<pre class="brush: powershell;">
Get-VMHost $esxName | Set-VMHostADDomain -ADJoin:$true -Domain 'test.local' -User 'Administrator' -Password 'MyPassword'
</pre>
<p>The Get-VMHostAuthentication function now returns.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/07/auth-local-and-ad.png"><img class="alignnone size-full wp-image-2513" title="auth-local-and-ad" src="http://lucd.info/wp-content/uploads/2010/07/auth-local-and-ad.png" alt="" width="626" height="73" /></a></p>
<p>You can also enable AD authentication on a series of ESX(i) hosts.</p>
<pre class="brush: powershell;">
Set-VMHostADDomain -VMhost (Get-VMHost) -ADJoin:$true -Domain 'test.local' -Credential (Get-Credential)
</pre>
<p>or like this</p>
<pre class="brush: powershell;">
Get-VMHost | Set-VMHostADDomain -ADJoin:$true -Domain 'test.local' -Credential (Get-Credential)
</pre>
<p>To remove a host, you have to set the <strong>-ADJoin</strong> switch to $false.<br />
Like this</p>
<pre class="brush: powershell;">
Get-VMHost | Set-VMHostADDomain -ADJoin:$false
</pre>
<p>The previous call assumes that there were no permissions with AD principals left on the ESX(i) server or any of it&#8217;s children.<br />
If there were, you would get an error message.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/07/ADAuthError.png"><img class="alignnone size-full wp-image-2510" title="ADAuthError" src="http://lucd.info/wp-content/uploads/2010/07/ADAuthError.png" alt="" width="690" height="52" /></a></p>
<p>You can let the &#8216;unjoin&#8217; remove any remaining permissions for you.<br />
For that you use the <strong>-RemovePermission</strong> parameter.</p>
<pre class="brush: powershell;">
Get-VMHost | Set-VMHostADDomain -ADJoin:$false -RemovePermission:$true
</pre>
<img src="http://feeds.feedburner.com/~r/LucdNotes/~4/KVFeBbubKMU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lucd.info/2010/07/25/script-vsphere-4-1-ad-authentication/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.lucd.info/2010/07/25/script-vsphere-4-1-ad-authentication/</feedburner:origLink></item>
		<item>
		<title>PowerCLI 4.1 brings the New-VIProperty cmdlet</title>
		<link>http://feedproxy.google.com/~r/LucdNotes/~3/LGn2-SN0IQc/</link>
		<comments>http://www.lucd.info/2010/07/13/powercli-4-1-brings-the-new-viproperty-cmdlet/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 07:55:58 +0000</pubDate>
		<dc:creator>LucD</dc:creator>
				<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[New-VIProperty]]></category>

		<guid isPermaLink="false">http://www.lucd.info/?p=2435</guid>
		<description><![CDATA[In the new PowerCLI 4.1 build 264274 there are two new cmdlets, called New-VIProperty and Remove-VIProperty, that deserve your special attention. The New-VIProperty cmdlet allows you to add a new properties to any PowerCLI object (InventoryItem, HostSystem, VirtualMachine&#8230;). And it&#8217;s up to you to define what the value of this new property will ! The [...]]]></description>
			<content:encoded><![CDATA[<p>In the <a href="http://communities.vmware.com/community/vmtn/vsphere/automationtools/powercli?view=overview" target="_blank">new PowerCLI 4.1 build 264274</a> there are two new cmdlets, called <a href="http://www.vmware.com/support/developer/PowerCLI/PowerCLI41/html/New-VIProperty.html" target="_blank">New-VIProperty</a> and <a href="http://www.vmware.com/support/developer/PowerCLI/PowerCLI41/html/Remove-VIProperty.html" target="_blank">Remove-VIProperty</a>, that deserve your special attention.</p>
<p>The <a href="http://www.vmware.com/support/developer/PowerCLI/PowerCLI41/html/New-VIProperty.html" target="_blank">New-VIProperty</a> cmdlet allows you to add a new properties to any PowerCLI object (InventoryItem, HostSystem, VirtualMachine&#8230;). And it&#8217;s up to you to define what the value of this new property will !</p>
<p>The <a href="http://www.vmware.com/support/developer/PowerCLI/PowerCLI41/html/Remove-VIProperty.html" target="_blank">Remove-VIProperty</a> cmdlet allows you to remove such a new property.</p>
<p>These new cmdlets, combined with the new <strong>Extension</strong> property, will change several of the well established ways that you use in your PowerCLI scripts. And besides adding a lot of flexibility, the extension property will make your scripts considerably faster (if used wisely).</p>
<p><span id="more-2435"></span></p>
<span id="What_is_an_extension_property"><h2>What is an extension property?</h2></span>
<p>In short, it&#8217;s a <strong>new property</strong> you add to any of the PowerCLI objects. You select the <strong>name</strong> of the property and also what will be the <strong>value</strong> of the new property.</p>
<p>An example will perhaps make it clearer.</p>
<p>Let&#8217;s take the PowerCLI <strong>Datastore</strong> object. It&#8217;s returned by the <a href="http://www.vmware.com/support/developer/PowerCLI/PowerCLI41/html/Get-Datastore.html" target="_blank">Get-Datastore</a> cmdlet and has the following properties.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/07/DS-object1.png"><img class="alignnone size-full wp-image-2444" title="DS-object" src="http://lucd.info/wp-content/uploads/2010/07/DS-object1.png" alt="" width="537" height="166" /></a></p>
<p>Notice the <strong>FreeSpaceMB</strong> and <strong>CapacityMB</strong> properties, which are both giving the values in <strong>MB</strong>.</p>
<p>You are now tasked to create a report containing the name of the datastore and the free space in <strong>GB</strong>.</p>
<p>Till now you had to do something like this:</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/07/DS-freespaceGB1.png"><img class="alignnone size-full wp-image-2439" title="DS-freespaceGB1" src="http://lucd.info/wp-content/uploads/2010/07/DS-freespaceGB1.png" alt="" width="704" height="59" /></a></p>
<p>And if you wanted this in a nicer format, you could do:</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/07/DS-freespaceGB2.png"><img class="alignnone size-full wp-image-2440" title="DS-freespaceGB2" src="http://lucd.info/wp-content/uploads/2010/07/DS-freespaceGB2.png" alt="" width="798" height="59" /></a></p>
<p>But with the <a href="http://www.vmware.com/support/developer/PowerCLI/PowerCLI41/html/New-VIProperty.html" target="_blank">New-VIProperty</a> cmdlet this can be done differently now.</p>
<p>First you define the new property. You specify a Name for the property, the PowerCLI object on which you want to add the new property and how the value of the new property shall be obtained/calculated.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/07/DS-freespaceGB-extprop.png"><img class="alignnone size-full wp-image-2442" title="DS-freespaceGB-extprop" src="http://lucd.info/wp-content/uploads/2010/07/DS-freespaceGB-extprop.png" alt="" width="757" height="30" /></a></p>
<p>And from now on you can use the new <strong>FreeSpaceGB</strong> property for example in a <strong>Select-Object</strong> cmdlet like this.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/07/DS-freespaceGB-extprop-select.png"><img class="alignnone size-full wp-image-2443" title="DS-freespaceGB-extprop-select" src="http://lucd.info/wp-content/uploads/2010/07/DS-freespaceGB-extprop-select.png" alt="" width="518" height="59" /></a></p>
<p>No more need to remember the tedious expression from before. You compose your <a href="http://www.vmware.com/support/developer/PowerCLI/PowerCLI41/html/New-VIProperty.html" target="_blank">New-VIProperty</a> cmdlet and the new property will be there each time you retrieve a Datastore object.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/07/DS-object-ext.png"><img class="alignnone size-full wp-image-2445" title="DS-object-ext" src="http://lucd.info/wp-content/uploads/2010/07/DS-object-ext.png" alt="" width="533" height="186" /></a></p>
<p><strong>Note </strong>that an extension property defined this way, will only exist for as long as you have your PowerCLI environment running.  If you restart your PowerCLI environment, the new property will not be there anymore.</p>
<p>If you want to have some of these new properties available each time you start your PowerCLI environment, you could for example place the <a href="http://www.vmware.com/support/developer/PowerCLI/PowerCLI41/html/New-VIProperty.html" target="_blank">New-VIProperty</a> statements in your profile.</p>
<span id="How_to_get_a_value_in_a_new_property"><h2>How to get a value in a new property?</h2></span>
<span id="Properties_from_the_PowerCLI_object."><h3>Properties from the PowerCLI object.</h3></span>
<p>In the previous example we populated the new property with a recalculated value of an existing property of the PowerCLI object. But there are other ways of setting the value of a new property.</p>
<p>In the sample script I used the <strong>$args[0]</strong> variable to refer to the PowerCLI object itself. You can also define the current PowerCLI object with the <strong>param</strong> statement.</p>
<pre class="brush: powershell;">
New-VIProperty -Name FreeSpaceGB -ObjectType Datastore -Value {
	&quot;{0:f1}&quot; -f ($Args[0].FreeSpaceMB/1KB)
}
</pre>
<p>is equivalent to</p>
<pre class="brush: powershell;">
New-VIProperty -Name FreeSpaceGB -ObjectType Datastore -Value {
	param($ds)

	&quot;{0:f1}&quot; -f ($ds.FreeSpaceMB/1KB)
}
</pre>
<span id="Properties_from_the_API_object."><h3>Properties from the API object.</h3></span>
<p>Suppose we are asked to provide per datastore how many guests are stored on that datastore. As always with PowerShell/PowerCLI there are many ways of doing this, but in this case we are going for the <a href="http://www.vmware.com/support/developer/PowerCLI/PowerCLI41/html/New-VIProperty.html" target="_blank">New-VIProperty</a> cmdlet.</p>
<p>In the API <a href="http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.Datastore.html" target="_blank">Datastore</a> object there is a property, called <strong>VM</strong>, that holds a <strong>MoRef</strong> to each guests stored on that datastore. If we count the number of entries in this property, we will have the number of guests.</p>
<p>In the <a href="http://communities.vmware.com/community/vmtn/vsphere/automationtools/powercli?view=overview" target="_blank">latest PowerCLI build</a> the complete API object is accessible under the <a href="http://www.vmware.com/support/developer/PowerCLI/PowerCLI41/html/ExtensionData.html" target="_blank">ExtensionData</a> propery. That will allow us to do something like this.</p>
<pre class="brush: powershell;">
New-VIProperty -Name VMcount -ObjectType Datastore -Value {
	param($ds)

	$ds.ExtensionData.Vm.Count
}
</pre>
<p>Great, we now have access to the complete <strong>API object</strong>. No more need to do a <a href="http://www.vmware.com/support/developer/PowerCLI/PowerCLI41/html/Get-View.html" target="_blank">Get-View</a> everytime we need the <strong>API object</strong>.<br />
But the tradeoff is that the mapping of the <strong>API object</strong> takes resources.</p>
<p>Your scripts will run longer when the API object has to be fetched and mapped each time a <strong>PowerCLI object</strong> is fetched.<br />
Luckily the <strong>PowerCLI Dev Team</strong> came up with a great solution!<br />
The ExtensionData property will only map to the API object when you <span style="text-decoration: underline;"><strong>access</strong></span> the property or any of the subproperties.<br />
And to make it even more optimal, the <strong>Dev Team</strong> introduced the <strong>-BasedOnExtensionProperty</strong> parameter.</p>
<p>This parameter allows you to specify which specific properties of the API object you are going to use in the <strong>-Value</strong> script block.</p>
<p>That way access can even be more optimised. In our sample this would become.</p>
<pre class="brush: powershell;">
New-VIProperty -Name VMcount -ObjectType Datastore -Value {
	param($ds)

	$ds.ExtensionData.Vm.Count
} -BasedOnExtensionProperty 'vm'
</pre>
<p>When you now run the <a href="http://www.vmware.com/support/developer/PowerCLI/PowerCLI41/html/Get-Datastore.html" target="_blank">Get-Datastore</a> cmdlet against a fair number of datastores, you will notice that the execution time will have improved dramatically.</p>
<span id="Properties_from_the_API_object_with_aggregation_functions."><h3>Properties from the API object with aggregation functions.</h3></span>
<p>Quite often the actions you have to take for the <strong>-Value</strong> parameter are simple one-to-one <strong>mappings</strong> or any of the following <strong>aggregation</strong> functions: SUM, AVERAGE or AVG, MIN, MAX, UNIQUE, COUNT.</p>
<p>With the <strong>-ValueFromExtensionProperty</strong> parameter you can use a simple mapping or one of the aggregation functions without setting up a complete script block.<br />
Our example would become</p>
<pre class="brush: powershell;">
New-VIProperty -Name VMcount -ObjectType Datastore -ValueFromExtensionProperty 'COUNT vm'
</pre>
<p>This concludes my short review of the <a href="http://www.vmware.com/support/developer/PowerCLI/PowerCLI41/html/New-VIProperty.html" target="_blank">New-VIProperty</a> and <a href="http://www.vmware.com/support/developer/PowerCLI/PowerCLI41/html/Remove-VIProperty.html" target="_blank">Remove-VIProperty</a> cmdlets.</p>
<p>Play around with these new cmdlets and feel free to post some of the amazing use cases you will no doubt come up with.</p>
<img src="http://feeds.feedburner.com/~r/LucdNotes/~4/LGn2-SN0IQc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lucd.info/2010/07/13/powercli-4-1-brings-the-new-viproperty-cmdlet/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		<feedburner:origLink>http://www.lucd.info/2010/07/13/powercli-4-1-brings-the-new-viproperty-cmdlet/</feedburner:origLink></item>
		<item>
		<title>Create VMFS datastores on “free space” partitions</title>
		<link>http://feedproxy.google.com/~r/LucdNotes/~3/zq-h7E1o7Tc/</link>
		<comments>http://www.lucd.info/2010/06/26/create-vmfs-datastores-on-a-free-space-partition/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 22:46:56 +0000</pubDate>
		<dc:creator>LucD</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[datastore]]></category>
		<category><![CDATA[vSphere]]></category>
		<category><![CDATA[partition]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[SDK]]></category>

		<guid isPermaLink="false">http://www.lucd.info/?p=2400</guid>
		<description><![CDATA[The New-Datastore cmdlet allows you to easily create VMFS datastores on a free LUN or local disk. But what if you want to create a VMFS datastore on that free partition you have left on a LUN or on a local disk ? These free GBs could come in handy and it&#8217;s a shame letting [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.vmware.com/support/developer/windowstoolkit/wintk40u1/html/New-Datastore.html" target="_blank">New-Datastore</a> cmdlet allows you to easily create <strong>VMFS</strong> datastores on a free <strong>LUN</strong> or<strong> local disk</strong>. But what if you want to create a VMFS datastore on that free partition you have left on a LUN or on a local disk ? These free GBs could come in handy and it&#8217;s a shame letting them go to waste. Unfortunately, the <a href="http://www.vmware.com/support/developer/windowstoolkit/wintk40u1/html/New-Datastore.html" target="_blank">New-Datastore</a> cmdlet doesn&#8217;t have an option (yet) to handle &#8220;free space&#8221; partitions.</p>
<p>Exactly such a question was raised by <strong>Alasdair</strong> in his thread <a href="http://communities.vmware.com/message/1559474#1559474" target="_blank">new-datastore on ESX4i Installable local disk</a> in the <a href="http://communities.vmware.com/community/vmtn/vsphere/automationtools/powercli" target="_blank">PowerCLI Community</a> recently.</p>
<p><span id="more-2400"></span>When you create a new datastore via the vSphere client and you select a LUN or local disk that has already partitions that are in use, you get two options.</p>
<p>You can select to take the <strong>complete</strong> LUN/local disk and this will remove the partitions that were already there.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/06/vmfs-part-all.png"><img class="alignnone size-full wp-image-2404" title="vmfs-part-all" src="http://lucd.info/wp-content/uploads/2010/06/vmfs-part-all.png" alt="" width="473" height="347" /></a></p>
<p>Or you can select the option to take the &#8220;<strong>free space</strong>&#8221; partition.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/06/vmfs-part-free.png"><img class="alignnone size-full wp-image-2405" title="vmfs-part-free" src="http://lucd.info/wp-content/uploads/2010/06/vmfs-part-free.png" alt="" width="477" height="338" /></a></p>
<p>The following functions will allow you to find the &#8220;free space&#8221; partitions and to create a VMFS datastore on such a partition.</p>
<span id="The_script"><h2>The script</h2></span>
<pre class="brush: powershell;">
function Get-ScsiFreePartition{
	param (
	[parameter(ValueFromPipeline = $true,Position=1)]
	[ValidateNotNullOrEmpty()]
	[VMware.VimAutomation.Client20.VMHostImpl]
	$VMHost
	)

	process{
		$esx = $VMHost | Get-View
		$storMgr = Get-View $esx.ConfigManager.DatastoreSystem
		$storSys = Get-View $esx.ConfigManager.StorageSystem

		$lunExt = $storMgr.QueryAvailableDisksForVmfs($null)
		foreach($lun in $lunExt){
			$info = $storMgr.QueryVmfsDatastoreCreateOptions($lun.DevicePath)
			foreach($dsOpt in $info){
				$info2 = $storSys.ComputeDiskPartitionInfo($lun.DevicePath,$dsOpt.Info.Layout)
				$info2.Layout.Partition | where {$_.Type -eq &quot;vmfs&quot;} | %{
					New-Object PSObject -Property @{
						DeviceName = $lun.DeviceName
						DeviceSizeMB = $lun.Capacity.block * $lun.Capacity.BlockSize / 1MB
						Partition = $_.Partition
						PartitionSizeMB = ($_.End.block - $_.Start.Block) * $_.Start.BlockSize / 1MB
						FullDisk = &amp;{if($_.Partition -eq 1){$true}else{$false}}
					}
				}
			}
		}
	}
}

function New-PartitionDatastore{
	param (
	[parameter(ValueFromPipeline = $true,Position=1)]
	[ValidateNotNullOrEmpty()]
	[VMware.VimAutomation.Client20.VMHostImpl]
	$VMHost,
	[parameter(Position=2)]
	[ValidateNotNullOrEmpty()]
	[PSObject]
	$Partition,
	[parameter(Position=3)]
	[ValidateNotNullOrEmpty()]
	[String]
	$Name
	)

	process{
		$esx = $VMHost | Get-View
		$storMgr = Get-View $esx.ConfigManager.DatastoreSystem

		$lunExt = $storMgr.QueryAvailableDisksForVmfs($null)
		$device = $lunExt | where {$_.DeviceName -eq $Partition.DeviceName}
		$dsOpt = $storMgr.QueryVmfsDatastoreCreateOptions($Partition.DeviceName) | where {$_.Info.VmfsExtent.Partition -eq $Partition.Partition}

		$spec = $dsOpt.Spec
		$spec.Vmfs.VolumeName = $Name
		$spec.Extent += $spec.Vmfs.Extent
		$dsMoRef = $storMgr.CreateVmfsDatastore($spec)
		Get-Datastore (Get-View $dsMoRef).Name
	}
}
</pre>
<span id="Annotations"><h4>Annotations</h4></span>
<p><strong>Line 14,53</strong>: The <a href="http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.host.DatastoreSystem.html#queryAvailableDisksForVmfs" target="_blank">QueryAvailableDisksForVmfs</a> method will return all disks that can be used to create VMFS datastores.</p>
<p><strong>Line 16,55</strong>: The <a href="http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.host.DatastoreSystem.html#queryVmfsDatastoreCreateOptions" target="_blank">QueryVmfsDatastoreCreateOptions</a> method will return all possible options to create (or extend) a datastore on the specific disk.</p>
<p><strong>Line 18</strong>: The <a href="http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.host.StorageSystem.html#computeDiskPartitionInfo" target="_blank">ComputeDiskPartitionInfo</a> method will determine the disk partition layout for the specified disk layout.</p>
<p><strong>Line 20-25</strong>: Creates and populates the objects with the available partition configurations.</p>
<p><strong>Line 57-59</strong>: Populate the <a href="http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.host.VmfsDatastoreCreateSpec.html" target="_blank">VmfsDatastoreCreateSpec</a> object.</p>
<p><strong>Line 60</strong>: Create the new VMFS datastore with the <a href="http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.host.DatastoreSystem.html#createVmfsDatastore" target="_blank">CreateVmfsDatastore</a> method.</p>
<p><strong>Line 61</strong>: Return a <strong>VMware.VimAutomation.Client20.DatastoreImpl</strong> object to make the function consistent with the New-Datastore cmdlet.</p>
<span id="Sample_runs"><h2>Sample runs</h2></span>
<p>With the <strong>Get-ScsiFreePartition</strong> you can find the &#8220;free space&#8221; partitions on LUNs or local disks connected to your ESX(i) server.</p>
<pre class="brush: powershell;">
$esxName = &quot;esx4i.test.local&quot;
$esxImpl = Get-VMHost -Name $esxName
$esxImpl | Get-ScsiFreePartition | ft -AutoSize
</pre>
<p>This will produce output similar to this.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/06/free-space-partition.png"><img class="alignnone size-full wp-image-2409" title="free-space-partition" src="http://lucd.info/wp-content/uploads/2010/06/free-space-partition.png" alt="" width="573" height="66" /></a></p>
<p>All returned partitions that are partition one mean the complete LUN or local disk. And they will hence destroy the existing data. For your convenience the function adds the FullDisk property which indicates this fact again.</p>
<p>If we want to use the &#8220;free space&#8221; partition, we have to do some filtering. Something like this for example</p>
<pre class="brush: powershell;">
$esxName = &quot;esx4i.test.local&quot;
$esxImpl = Get-VMHost -Name $esxName
$partition = $esxImpl | Get-ScsiFreePartition | where {!$_.FullDisk} | Select -First 1
$esxImpl | New-PartitionDatastore -Partition $partition -Name &quot;MyDS&quot;
</pre>
<p>will create a new VMFS datastore on the first &#8220;<strong>free space</strong>&#8221; partition and the datastore will be named <strong>MyDS</strong>.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/06/ds-new.png"><img class="alignnone size-full wp-image-2412" title="ds-new" src="http://lucd.info/wp-content/uploads/2010/06/ds-new.png" alt="" width="557" height="316" /></a></p>
<p>The properties of the datastore show that it is located on partition 3, the previous &#8220;free space&#8221; partition.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/06/ds-properties.png"><img class="alignnone size-full wp-image-2413" title="ds-properties" src="http://lucd.info/wp-content/uploads/2010/06/ds-properties.png" alt="" width="548" height="348" /></a></p>
<p>Notice that the <strong>New-PartitionDatastore</strong> returns the newly created datastore, similar to what the <strong>New-Datastore</strong> cmdlet does.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/06/ds-free-space-partition.png"><img class="alignnone size-full wp-image-2411" title="ds-free-space-partition" src="http://lucd.info/wp-content/uploads/2010/06/ds-free-space-partition.png" alt="" width="451" height="45" /></a></p>
<img src="http://feeds.feedburner.com/~r/LucdNotes/~4/zq-h7E1o7Tc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lucd.info/2010/06/26/create-vmfs-datastores-on-a-free-space-partition/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.lucd.info/2010/06/26/create-vmfs-datastores-on-a-free-space-partition/</feedburner:origLink></item>
		<item>
		<title>Events – Part 8 – vMotion history</title>
		<link>http://feedproxy.google.com/~r/LucdNotes/~3/ocvOIx3ErCs/</link>
		<comments>http://www.lucd.info/2010/06/22/events-part-8-vmotion-history/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 21:44:41 +0000</pubDate>
		<dc:creator>LucD</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[vMotion]]></category>
		<category><![CDATA[vSphere]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[SDK]]></category>

		<guid isPermaLink="false">http://www.lucd.info/?p=2385</guid>
		<description><![CDATA[Another idea triggered by a post in the PowerCLI Community. Lars wanted to know where his VMs had been running in the past. Since vSphere doesn&#8217;t maintain any historical data with the guests themselves, we have to fall back on the Tasks and Events to create such a report. The basic algorithm to query the [...]]]></description>
			<content:encoded><![CDATA[<p>Another idea triggered by a post in the <a href="http://communities.vmware.com/community/vmtn/vsphere/automationtools/powercli" target="_blank">PowerCLI Community</a>. <strong>Lars</strong> wanted to know <a href="http://communities.vmware.com/thread/273355?tstart=0" target="_blank">where his VMs had been running</a> in the past.</p>
<p>Since <strong>vSphere</strong> doesn&#8217;t maintain any historical data with the guests themselves, we have to fall back on the <strong>Tasks and Events</strong> to create such a report. The basic algorithm to query the tasks, and their related events, is already published in <a href="http://www.lucd.info/2009/12/18/events-part-3-auditing-vm-device-changes/" target="_blank">Events – Part 3 : Auditing VM device changes</a>. But to get a historical record of the servers where your guests have been hosted requires a bit more logic in the script.</p>
<span id="The_script"><h2><span id="more-2385"></span>The script</h2></span>
<p>There are 2 distinct parts in the script.</p>
<ol>
<li>Get all the vMotion tasks. A <strong>vMotion</strong> can be <strong>user</strong>- or <strong>DRS</strong>-initiated. These produce different tasks.</li>
<li>Compile the final report by only looking at the <strong>selected guests</strong></li>
</ol>
<pre class="brush: powershell;">
$hours = 24 # Number of hours back
$start = (Get-Date).AddHours(-$hours)
$tasknumber = 999 # Windowsize for task collector
$eventnumber = 100 # Windowsize for event collector
$tgtTaskDescriptions = &quot;VirtualMachine.migrate&quot;,&quot;Drm.ExecuteVMotionLRO&quot;
$migrations = @()
$report = @()

# Get the guest for which we want the report
$vmHash = @{}
Get-Datacenter -Name &quot;MyDC&quot; | Get-VM | %{
	$vmHash[$_.Name] = $_.Host
}

# Retrieve the vMotion tasks and the corresponding events
$taskMgr = Get-View TaskManager
$eventMgr = Get-View eventManager

$tFilter = New-Object VMware.Vim.TaskFilterSpec
$tFilter.Time = New-Object VMware.Vim.TaskFilterSpecByTime
$tFilter.Time.beginTime = $start
$tFilter.Time.timeType = &quot;startedTime&quot;

$tCollector = Get-View ($taskMgr.CreateCollectorForTasks($tFilter))

$dummy = $tCollector.RewindCollector
$tasks = $tCollector.ReadNextTasks($tasknumber)

while($tasks){
	$tasks | where {$tgtTaskDescriptions -contains $_.DescriptionId} | % {
		$task = $_
		$eFilter = New-Object VMware.Vim.EventFilterSpec
		$eFilter.eventChainId = $task.EventChainId

		$eCollector = Get-View ($eventMgr.CreateCollectorForEvents($eFilter))
		$events = $eCollector.ReadNextEvents($eventnumber)
		while($events){
			$events | % {
				$event = $_
				switch($event.GetType().Name){
					&quot;VmBeingHotMigratedEvent&quot; {
						$migrations += New-Object PSObject -Property @{
							VMname = $task.EntityName
							Source = $event.Host.Name
							Destination = $event.DestHost.Name
							Start = $task.StartTime
							Finish = $task.CompleteTime
							Result = $task.State
							User = $task.Reason.UserName
							DRS = &amp;{if($task.DescriptionId -like &quot;Drm.*&quot;){$true}else{$false}}
						}
					}
					Default {}
				}
			}
			$events = $eCollector.ReadNextEvents($eventnumber)
		}
		$ecollection = $eCollector.ReadNextEvents($eventnumber)
# By default 32 event collectors are allowed. Destroy this event collector.
		$eCollector.DestroyCollector()
	}
	$tasks = $tCollector.ReadNextTasks($tasknumber)
}

# By default 32 task collectors are allowed. Destroy this task collector.
$tCollector.DestroyCollector()

# Handle the guests that have been vMotioned
$grouped = $migrations | Group-Object -Property VMname
$grouped | Sort-Object -Property Count -Descending | where{$vmHash.ContainsKey($_.Name)} | %{
	$i = 1
	$row = New-Object PSObject
	Add-Member -InputObject $row -Name VM -Value $_.Name -MemberType NoteProperty
	$_.Group | Sort-Object -Property Finish | %{
# The original location of the guest
		if($i -eq 1){
			Add-Member -InputObject $row -Name (&quot;Time&quot; + $i) -Value $start -MemberType NoteProperty
			Add-Member -InputObject $row -Name (&quot;Host&quot; + $i) -Value $_.Source -MemberType NoteProperty
			$i++
		}
# All the vMotion destinations
		Add-Member -InputObject $row -Name (&quot;Time&quot; + $i) -Value $_.Finish -MemberType NoteProperty
		Add-Member -InputObject $row -Name (&quot;Host&quot; + $i) -Value $_.Destination -MemberType NoteProperty
		Add-Member -InputObject $row -Name (&quot;DRS&quot; + $i) -Value $_.DRS -MemberType NoteProperty
		Add-Member -InputObject $row -Name (&quot;User&quot; + $i) -Value $_.User -MemberType NoteProperty
		$i++
	}
	$report += $row
	$vmHash.Remove($_.Name)
}

# Add remaining guests to report
$vmHash.GetEnumerator() | %{
	$row = New-Object PSObject
	Add-Member -InputObject $row -Name VM -Value $_.Name -MemberType NoteProperty
	Add-Member -InputObject $row -Name Time1 -Value $start -MemberType NoteProperty
	Add-Member -InputObject $row -Name Host1 -Value $_.Value -MemberType NoteProperty
	Add-Member -InputObject $row -Name DRS1 -Value $false -MemberType NoteProperty
	$report += $row
}

$report | Export-Csv &quot;C:\vMotion-history.csv&quot; -NoTypeInformation -UseCulture
</pre>
<span id="Annotations"><h4>Annotations</h4></span>
<p><strong>Line 1-2</strong>: Specify how far back you want to report on through the <strong>$start</strong> variable</p>
<p><strong>Line 5</strong>: The vMotion tasks can be triggered by a user or by DRS.</p>
<p><strong>Line 10-13</strong>: We collect all the guests on which we want to report. This can be changed at will, just make sure the hash table <strong>$vmHash</strong> is populated.</p>
<p><strong>Line 15-66</strong>: This is the same logic as was used in <a href="http://www.lucd.info/2009/12/18/events-part-3-auditing-vm-device-changes/" target="_blank">Events – Part 3 : Auditing VM device changes</a></p>
<p><strong>Line 69-70</strong>: We group the discovered vMotions per guest and then we sort the groups descending on the Count property. This is required because we will later use the Export-Csv cmdlet and if the array holds rows of varying length, the longest row should be first.</p>
<p><strong>Line 76-80</strong>: For the vMotioned guest we first make an entry with the original location at time $start.</p>
<p><strong>Line 82-86</strong>: For each vMotion we add the same properties Time, Host, DRS and User, but each time with an incremented suffix number.</p>
<p><strong>Line 89</strong>: A guest that was vMotioned is removed from hash table to avoid duplicate entries later one.</p>
<p><strong>Line 93-100</strong>: The guest that were not vMotioned during the reporting interval are added to the report.</p>
<span id="Sample_output"><h2>Sample output</h2></span>
<p>The script produces a CSV file that contains quite a bit of information.</p>
<p>A guest that was <span style="background-color: #00ff00;">not vMotioned</span> during the reporting interval will only have a <strong>Time1</strong> and <strong>Host1</strong> column.</p>
<p>Guests that were vMotioned will have additional <span style="background-color: #ffff00;"><strong>Time<em>n</em></strong> and <strong>Host<em>n</em></strong></span> columns. Notice the <span style="background-color: #99ccff;"><strong>DRS<em>n</em></strong></span> column which indicates if a vMotion was triggered by DRS or by a user.  The <span style="background-color: #ff99cc;"><strong>User<em>n</em></strong></span> column will display the username if it was a user-invoked vMotion.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/06/vMotion-history.png"><img class="alignnone size-full wp-image-2392" title="vMotion-history" src="http://lucd.info/wp-content/uploads/2010/06/vMotion-history.png" alt="" width="833" height="333" /></a></p>
<img src="http://feeds.feedburner.com/~r/LucdNotes/~4/ocvOIx3ErCs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lucd.info/2010/06/22/events-part-8-vmotion-history/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.lucd.info/2010/06/22/events-part-8-vmotion-history/</feedburner:origLink></item>
		<item>
		<title>Script ‘esxupdate -query’</title>
		<link>http://feedproxy.google.com/~r/LucdNotes/~3/JgcjWMhQbVU/</link>
		<comments>http://www.lucd.info/2010/06/21/script-esxupdate-query/#comments</comments>
		<pubDate>Mon, 21 Jun 2010 17:55:20 +0000</pubDate>
		<dc:creator>LucD</dc:creator>
				<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Update Manager]]></category>
		<category><![CDATA[VUM]]></category>
		<category><![CDATA[SDK]]></category>

		<guid isPermaLink="false">http://www.lucd.info/?p=2366</guid>
		<description><![CDATA[I received an interesting comment on my Events – Part 7 : Working with extended events – Update Manager post from Suresh. He wanted to know if it was possible to create a similar report with the vCenter Update Manager PowerCLI cmdlets as you can get with the esxupdate query command. After some deep-diving in [...]]]></description>
			<content:encoded><![CDATA[<p>I received an interesting comment on my <a href="http://www.lucd.info/2010/06/15/events-part-7-working-with-extended-events-update-manager/" target="_blank">Events – Part 7 : Working with extended events – Update Manager</a> post from Suresh. He wanted to know if it was possible to create a similar report with the <a href="http://communities.vmware.com/community/vmtn/vsphere/automationtools/powercli/updatemanager?view=overview" target="_blank">vCenter Update Manager PowerCLI</a> cmdlets as you can get with the <em><strong>esxupdate query</strong></em> command.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/06/esxupdate-query.png"><img class="alignnone size-full wp-image-2369" title="esxupdate-query" src="http://lucd.info/wp-content/uploads/2010/06/esxupdate-query.png" alt="" width="586" height="263" /></a></p>
<p><span id="more-2366"></span>After some deep-diving in the <strong>VMware.VumAutomation</strong> cmdlets, I discovered that this question could probably not be answered with the <strong>VMware.VumAutomation</strong> cmdlets  . On top of that, the current build seems to have a <a href="http://communities.vmware.com/thread/273156?tstart=0" target="_blank">problem</a> with <strong>Get-Baseline</strong> cmdlet when you use the <strong>-Inherit</strong> parameter.</p>
<p>So, as always, into the SDK <img src='http://lucd.info/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Luckily, the <a href="http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.host.PatchManager.html" target="_blank">HostPatchManager</a> holds the answer. Via the <a href="http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.host.PatchManager.html#Query" target="_blank">QueryHostPatch_Task</a> method you have access to all the installed bulletins.</p>
<p><span style="background-color: #ffff00;"><strong>Update June 25th 2010</strong></span>: after comments from Suresh and James I investigated what goes wrong when you run the script against an ESXi server. It turned out that the <a href="http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.host.PatchManager.html#Query" target="_blank">QueryHostPatch_Task</a> method doesn&#8217;t return the bulletins for ESXi hosts.</p>
<p>And this seems to be consistent with the behaviour of the <em><strong>esxupdate query</strong></em> command.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/06/ESXi-patchmgr.png"><img class="alignnone size-full wp-image-2396" title="ESXi-patchmgr" src="http://lucd.info/wp-content/uploads/2010/06/ESXi-patchmgr.png" alt="" width="518" height="268" /></a></p>
<p>I&#8217;m not sure if this is to be considered a bug or if this is intentional !</p>
<p>The script has been updated to display a warning when run against an ESXi server.</p>
<p><span style="background-color: #ffff00;"><strong>Update June 30th 2010</strong></span>: After further investigation it looks as if the problem only exist for <strong>ESXi 4</strong> and <strong>ESXi 4u1</strong> servers.  Until further conclusive test I have adapted the script.</p>
<span id="The_script"><h2>The script</h2></span>
<pre class="brush: powershell;">
$report = @()
Get-View -ViewType HostSystem -Filter @{&quot;Name&quot;=&quot;esx4i.test.local&quot;} | %{
	$esx = $_
	if($esx.Config.Product.ProductLineId -ne &quot;embeddedesx&quot; -or ($esx.Config.Product.ProductLineId -eq &quot;embeddedesx&quot; -and $esx.Config.Product.Build -ge 261974)){
		$patchMgr = Get-View $esx.ConfigManager.PatchManager
# 	$spec = New-Object VMware.Vim.HostPatchManagerPatchManagerOperationSpec
# 	$spec.cmdOption = &quot;-a&quot;
# 	$taskMoRef = $patchMgr.QueryHostPatch_Task($spec)
		$taskMoRef = $patchMgr.QueryHostPatch_Task($null)
		$task = Get-View $taskMoRef
		while(&quot;running&quot;,&quot;queued&quot; -contains $task.Info.State){
			sleep 2
			$task.UpdateViewData(&quot;Info&quot;)
		}
		$result = [xml]$task.Info.Result.XmlResult
		$result.&quot;esxupdate-response&quot;.bulletin | %{
			$row = &quot;&quot; | Select ESX,&quot;Bulletin ID&quot;,Installed,Summary
			$row.ESX = $esx.Name
			$row.&quot;Bulletin ID&quot; = $_.id
			$row.Installed = [datetime]$_.installDate
			$row.Summary = $_.summary
			$report += $row
		}
	}
	else{
		Write-Host -fo red &quot;Host: &quot; -NoNewline
		Write-Host -fo white $esx.Name -NoNewline
		Write-Host -fo red &quot; OS: &quot; -NoNewline
		Write-Host -fo white $esx.Config.Product.FullName -NoNewline
		Write-Host -fo gray &quot; does not support the QueryHostPatch method&quot;
	}
}
$report | Sort-Object -Property ESX,Installed | ft -AutoSize
</pre>
<span id="Annotations"><h4>Annotations</h4></span>
<p><strong>Line 4</strong>: Check if the host runs an ESXi version.</p>
<p><strong>Line 9</strong>: For our initial purpose we don&#8217;t need any of the properties in the <a href="http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.host.PatchManager.PatchManagerOperationSpec.html" target="_blank">HostPatchManagerPatchManagerOperationSpec</a> object. Note that you could pass <strong>esxupdate</strong> options. If you add for example the option -a, the method will return all bulletins, not just the ones that are applicable. You will need to uncomment lines 6-8 and comment out line 9.</p>
<p><strong>Line 15</strong>: The result is returned as an XML object.</p>
<p><strong>Line 16</strong>: All returned bulletins are a node under <strong>&#8220;esxupdate-response&#8221;.bulletin</strong>. Note that we need the quotes around the first path element, otherwise the dash would pose problems.<strong><br />
</strong></p>
<span id="Sample_output"><h2>Sample output</h2></span>
<p>The script, as it is written above, dumps the results to the console. But you can just as well send the results to a <strong>CSV</strong> or <strong>XLS</strong> (see my <a href="http://www.lucd.info/2010/05/29/beyond-export-csv-export-xls/" target="_blank">Beyond Export-Csv: Export-Xls</a> post) file.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/06/ps-esxupdate-query.png"><img class="alignnone size-full wp-image-2370" title="ps-esxupdate-query" src="http://lucd.info/wp-content/uploads/2010/06/ps-esxupdate-query.png" alt="" width="622" height="298" /></a></p>
<p>Note that the script can run against all or a selection of your ESX servers in 1 run. You can use the -Filter parameter on the Get-View cmdlet or you can use a Where-Object cmdlet to select specific ESX hosts.</p>
<p>If one of the hosts you selected runs an ESXi version, the script will display a message on the console.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/06/ESXi-message1.png"><img class="alignnone size-full wp-image-2398" title="ESXi-message" src="http://lucd.info/wp-content/uploads/2010/06/ESXi-message1.png" alt="" width="809" height="30" /></a></p>
<p>A nice addition to your daily reports for your ESX servers.</p>
<img src="http://feeds.feedburner.com/~r/LucdNotes/~4/JgcjWMhQbVU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lucd.info/2010/06/21/script-esxupdate-query/feed/</wfw:commentRss>
		<slash:comments>34</slash:comments>
		<feedburner:origLink>http://www.lucd.info/2010/06/21/script-esxupdate-query/</feedburner:origLink></item>
		<item>
		<title>Events – Part 7 : Working with extended events – Update Manager</title>
		<link>http://feedproxy.google.com/~r/LucdNotes/~3/afXxHrd7rHs/</link>
		<comments>http://www.lucd.info/2010/06/15/events-part-7-working-with-extended-events-update-manager/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 19:22:25 +0000</pubDate>
		<dc:creator>LucD</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Update Manager]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[vSphere]]></category>
		<category><![CDATA[PowerCLI]]></category>

		<guid isPermaLink="false">http://www.lucd.info/?p=2340</guid>
		<description><![CDATA[As I already mentioned in my previous post, Events &#8211; Part 6 : Working with extended events &#8211; Converter, another add-on that produces extended events, is the Update Manager. With the recent introduction of the vCenter Update Manager PowerCLI snapin, it is now fairly easy to automate all aspects of patch and update management in [...]]]></description>
			<content:encoded><![CDATA[<p>As I already mentioned in my previous post, <a href="http://www.lucd.info/2010/06/06/events-part-6-working-with-extended-events-converter/" target="_blank">Events &#8211; Part 6 : Working with extended events &#8211; Converter</a>, another<br />
add-on that produces extended events, is the <strong>Update Manager</strong>.</p>
<p>With the recent introduction of the <a href="http://communities.vmware.com/community/vmtn/vsphere/automationtools/powercli/updatemanager?view=overview" target="_blank">vCenter Update Manager PowerCLI</a> snapin, it is now fairly easy to automate all aspects of patch and update management in your vSphere environment. And with the help of the extended events produced by Update Manager, you can easily produce reports. This post shows one way of doing this.</p>
<p><span id="more-2340"></span></p>
<span id="The_events"><h2>The events</h2></span>
<p>Again we take the 2nd script from the <a href="http://www.lucd.info/2009/11/18/events-dear-boy-events-part-2/" target="_blank"> Events,  Dear Boy, Events – Part 2</a> post and we produce a spreadsheet with all the events known in our vSphere environment.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/06/UM-events-list.png"><img class="alignnone size-full wp-image-2342" title="UM-events-list" src="http://lucd.info/wp-content/uploads/2010/06/UM-events-list.png" alt="" width="566" height="411" /></a></p>
<p>As you can see the events coming from <strong>Update Manager</strong> can be recognised by the value in the <strong>Description</strong> field. All event types for Update Manager start with the text <strong>com.vmware.vcIntegrity</strong> in this field.</p>
<p>This allows us to easily filter out all the events for the Update Manager report.</p>
<p>Unfortunately there is, afaik, no documentation available on the  exact contents of these events. So if you want to use them, there will be  a bit of reverse-engineering and guess-work involved. But with what you can see in the <strong>Task&amp;Events</strong> tab in the <strong>vSphere client</strong>, you have a fairly good idea of what is available in these events.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/06/UM-remediate-task.png"><img class="alignnone size-full wp-image-2345" title="UM-remediate-task" src="http://lucd.info/wp-content/uploads/2010/06/UM-remediate-task.png" alt="" width="750" height="164" /></a></p>
<p>Btw there are <strong>124 different</strong> events the Update Manager can produce  ! So there is a lot more information out there.</p>
<span id="The_script"><h2>The script</h2></span>
<pre class="brush: powershell;">
$events = Get-VIEvent -Start (Get-Date).AddDays(-1) | `
	where {$_.EventTypeId -like &quot;com.vmware.vcIntegrity*&quot;} | `
	Sort-Object -Property CreatedTime
$events | %{
	New-Object PSObject -Property @{
		Date = $_.CreatedTime
		User = $_.UserName
		Host = $_.Host.Name
		Message = $_.FullFormattedMessage
	}
} | Export-Csv &quot;C:\Update-Manager-report.csv&quot; -NoTypeInformation -UseCulture
</pre>
<span id="Annotations"><h4>Annotations</h4></span>
<p><strong>Line 2</strong>: The filter only lets Update Manager events through</p>
<p><strong>Line 3</strong>: If you want the output in chronological order you better sort the events on their creation time.</p>
<p><strong>Line 5</strong>: When using the <strong>New-Object</strong> cmdlet with the -Property<strong> hash table</strong>, there is no way you can determine the order in which the properties will appear in the objects. This is a known &#8220;feature&#8221; and there are some open questions to change or influence this behaviour.</p>
<span id="Sample_output"><h2>Sample output</h2></span>
<p>All in all this is a rather simple and straightforward script, but it will allow you to add the Update Manager activities to your daily vSphere reporting.</p>
<p>The produced spreadsheet looks something like this. Note that the order of the columns will vary.</p>
<p><a href="http://lucd.info/wp-content/uploads/2010/06/UM-report-csv.png"><img class="alignnone size-full wp-image-2349" title="UM-report-csv" src="http://lucd.info/wp-content/uploads/2010/06/UM-report-csv.png" alt="" width="768" height="394" /></a></p>
<p>The Update Manager events allow for more advanced reports.</p>
<p>You could for example maintain a list that records at which precise date and time a specific patch was applied to which entity. Could be quite useful when problem solving.</p>
<p>Let me know if there is any interest in such a script and I&#8217;ll cook something together <img src='http://lucd.info/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<img src="http://feeds.feedburner.com/~r/LucdNotes/~4/afXxHrd7rHs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lucd.info/2010/06/15/events-part-7-working-with-extended-events-update-manager/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.lucd.info/2010/06/15/events-part-7-working-with-extended-events-update-manager/</feedburner:origLink></item>
	</channel>
</rss>
