<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>vin01 Tracker</title>
    <link>https://communities.vmware.com/wbsdv95928/tracker</link>
    <description>vin01 Tracker</description>
    <pubDate>Wed, 15 Nov 2023 10:27:13 GMT</pubDate>
    <dc:date>2023-11-15T10:27:13Z</dc:date>
    <item>
      <title>Re: Compliance check of NTFS permission on the vCenter server</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Compliance-check-of-NTFS-permission-on-the-vCenter-server/m-p/2915020#M107089</link>
      <description>&lt;P&gt;Hi LucD,&lt;/P&gt;&lt;P&gt;Sorry to pull you on the old thread. I am just trying something similar which is mentioned in the thread.&lt;/P&gt;&lt;P&gt;I am trying to get list of users mentioned in the share tab of the folder security advanced settings but unable to&amp;nbsp; get exact cmdlet. (see below snippet). Looking for the information which is highlighted in yellow.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Get-Acl -Path "\\share\folder1"&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vin01_0-1655742134066.png" style="width: 400px;"&gt;&lt;img src="https://communities.vmware.com/t5/image/serverpage/image-id/95869iBDD89C12D6C2D42F/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="vin01_0-1655742134066.png" alt="vin01_0-1655742134066.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jun 2022 16:24:00 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Compliance-check-of-NTFS-permission-on-the-vCenter-server/m-p/2915020#M107089</guid>
      <dc:creator>vin01</dc:creator>
      <dc:date>2022-06-20T16:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: general powershell question on start-job</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/general-powershell-question-on-start-job/m-p/2295995#M81254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks LucD. Script execution speed improved after setting throttlelimit &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Oct 2020 12:50:52 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/general-powershell-question-on-start-job/m-p/2295995#M81254</guid>
      <dc:creator>vin01</dc:creator>
      <dc:date>2020-10-13T12:50:52Z</dc:date>
    </item>
    <item>
      <title>general powershell question on start-job</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/general-powershell-question-on-start-job/m-p/2295993#M81252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to telnet 4125 Ips using Test-NetConnection. The below is the script. Here I used the script to execute in Parallel as a job. However After executing the job when I verified the child jobs only 5 jobs are running at single point of time and other jobs are in not started state. &lt;/P&gt;&lt;P&gt;My question is can we increase the execution process of child jobs to more then 5?&lt;/P&gt;&lt;DIV&gt;&lt;P&gt;$ipslistcsv=Import-Csv -Path C:\Users\testuser\Desktop\VLANSORTEDLIST.csv -UseCulture&lt;/P&gt;&lt;P&gt;$scriptasjob= $ipslistcsv | ForEach-Object -Parallel {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ((Test-NetConnection -ComputerName $_.IP -Port 3389 -WarningAction SilentlyContinue -ErrorAction SilentlyContinue).TcpTestSucceeded -eq $true) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Connection establisted sucessfully over port 3389 for IP $($_.IP)"&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elseif ((Test-NetConnection -ComputerName $_.IP -Port 22 -WarningAction SilentlyContinue -ErrorAction SilentlyContinue).TcpTestSucceeded -eq $true) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Connection establisted sucessfully over port 22 for IP $($_.IP)"&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "No Connection establised for IP $($_.IP)"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } -AsJob&lt;/P&gt;&lt;P&gt;(Get-Job -Id $scriptasjob.id).ChildJobs&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;img src="https://communities.vmware.com/t5/image/serverpage/image-id/23827iBD573B68034D5F8C/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_2.png" alt="pastedImage_2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Oct 2020 10:33:24 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/general-powershell-question-on-start-job/m-p/2295993#M81252</guid>
      <dc:creator>vin01</dc:creator>
      <dc:date>2020-10-13T10:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: Failed to convert to json</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Failed-to-convert-to-json/m-p/2297293#M81402</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am following this blog (&lt;A href="https://www.jonathanmedd.net/2016/01/create-blueprints-in-vra-7-via-rest-and-via-vro.html" title="https://www.jonathanmedd.net/2016/01/create-blueprints-in-vra-7-via-rest-and-via-vro.html"&gt;https://www.jonathanmedd.net/2016/01/create-blueprints-in-vra-7-via-rest-and-via-vro.html&lt;/A&gt; &amp;amp; &lt;A href="https://docs.vmware.com/en/vRealize-Automation/7.0/vrealize-automation-70-programming-guide.pdf" title="https://docs.vmware.com/en/vRealize-Automation/7.0/vrealize-automation-70-programming-guide.pdf"&gt;https://docs.vmware.com/en/vRealize-Automation/7.0/vrealize-automation-70-programming-guide.pdf&lt;/A&gt; ) to create blueprint in vRA. Here author used Postman REST client and I am using the same api with powershell.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After replacing like below I got response success and package got created.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_15995622193422816 jive_text_macro" data-renderedposition="112_8_1232_96" jivemacro_uid="_15995622193422816"&gt;&lt;P&gt;$contentneedtojson=@{&lt;/P&gt;&lt;P&gt;"name"="Vin Test packages"&lt;/P&gt;&lt;P&gt;"description"="Vineeth Test package for export"&lt;/P&gt;&lt;P&gt;"contents"=[System.Object[]]"bc3f4cbc-a697-4da4-b275-2161bc0d561f"&lt;/P&gt;&lt;P&gt;} &lt;/P&gt;&lt;P&gt;$contentjson=$contentneedtojson |ConvertTo-Json&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Expected package is created in vRA as below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@type&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : Package&lt;/P&gt;&lt;P&gt;id&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : c85234d0-5a5a-44aa-94c2-674920ab14d1&lt;/P&gt;&lt;P&gt;name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : Vin Test package&lt;/P&gt;&lt;P&gt;description : Vineeth Test package for export&lt;/P&gt;&lt;P&gt;tenantId&amp;nbsp;&amp;nbsp;&amp;nbsp; : SEZ18&lt;/P&gt;&lt;P&gt;subtenantId :&lt;/P&gt;&lt;P&gt;contents&amp;nbsp;&amp;nbsp;&amp;nbsp; : {bc3f4cbc-a697-4da4-b275-2161bc0d561f}&lt;/P&gt;&lt;P&gt;createdDate : 9/8/2020 8:18:35 AM&lt;/P&gt;&lt;P&gt;lastUpdated : 9/8/2020 8:18:35 AM&lt;/P&gt;&lt;P&gt;version&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 0&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Sep 2020 10:50:58 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Failed-to-convert-to-json/m-p/2297293#M81402</guid>
      <dc:creator>vin01</dc:creator>
      <dc:date>2020-09-08T10:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: Failed to convert to json</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Failed-to-convert-to-json/m-p/2297291#M81400</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have tried that but showing below error&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://communities.vmware.com/t5/image/serverpage/image-id/22818i0D758B3191B0CA87/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Sep 2020 10:19:11 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Failed-to-convert-to-json/m-p/2297291#M81400</guid>
      <dc:creator>vin01</dc:creator>
      <dc:date>2020-09-08T10:19:11Z</dc:date>
    </item>
    <item>
      <title>Failed to convert to json</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Failed-to-convert-to-json/m-p/2297289#M81398</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Requesting someone to help on this,&amp;nbsp; This is not&amp;nbsp; PowerCLI specific, but I'm using PowerShell to interact vRA using restapi to create a blueprint(Reference blog#&lt;A href="https://www.jonathanmedd.net/2016/01/create-blueprints-in-vra-7-via-rest-and-via-vro.html" title="https://www.jonathanmedd.net/2016/01/create-blueprints-in-vra-7-via-rest-and-via-vro.html"&gt;https://www.jonathanmedd.net/2016/01/create-blueprints-in-vra-7-via-rest-and-via-vro.html&lt;/A&gt; ). Below contents need to be converted to JSON but its showing error&lt;/P&gt;&lt;P&gt;Missing type name after '['.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN style="color: #9cdcfe;"&gt;$contentneedtojson&lt;/SPAN&gt;=&lt;SPAN style="color: #569cd6;"&gt;@&lt;/SPAN&gt;{&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ce9178;"&gt;"name"&lt;/SPAN&gt;=&lt;SPAN style="color: #ce9178;"&gt;"Vin Test package"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ce9178;"&gt;"description"&lt;/SPAN&gt;=&lt;SPAN style="color: #ce9178;"&gt;"Vineeth Test package for export"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ce9178;"&gt;"contents"&lt;/SPAN&gt;=[&lt;SPAN style="color: #ce9178;"&gt;"bc3f4cbc-a697-4da4-b275-2161bc0d561f"&lt;/SPAN&gt;]&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #9cdcfe;"&gt;$contentjson&lt;/SPAN&gt;=&lt;SPAN style="color: #9cdcfe;"&gt;$contentneedtojson&lt;/SPAN&gt; |&lt;SPAN style="color: #dcdcaa;"&gt;ConvertTo-Json&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #9cdcfe;"&gt;$contentjson&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://communities.vmware.com/t5/image/serverpage/image-id/22817i356CDE8B562A2B46/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Sep 2020 07:48:48 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Failed-to-convert-to-json/m-p/2297289#M81398</guid>
      <dc:creator>vin01</dc:creator>
      <dc:date>2020-09-08T07:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: all windows templates patching in a datacenter</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/all-windows-templates-patching-in-a-datacenter/m-p/2289990#M80542</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks LucD. Now the results are showing correctly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Sep 2020 04:37:20 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/all-windows-templates-patching-in-a-datacenter/m-p/2289990#M80542</guid>
      <dc:creator>vin01</dc:creator>
      <dc:date>2020-09-03T04:37:20Z</dc:date>
    </item>
    <item>
      <title>all windows templates patching in a datacenter</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/all-windows-templates-patching-in-a-datacenter/m-p/2289988#M80540</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi LucD,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have finally completed the below script to do windows updates on all templates in a datacenter using a DHCP vLan. Thanks for your support.&lt;/P&gt;&lt;P&gt;I need one fix in the script output. After updating windows I am writing output in a csv but that is not writing in correcting format. Every VMs output is written twice and leaving blank rows between every vms output. Sample output&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_0.png"&gt;&lt;img src="https://communities.vmware.com/t5/image/serverpage/image-id/22650iAE090A2E380523B3/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_0.png" alt="pastedImage_0.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="_jivemacro_uid_15988665356655067 jive_macro_code jive_text_macro" data-renderedposition="1580_8_1215_3600" jivemacro_uid="_15988665356655067"&gt;&lt;P&gt;$location=Get-Location&lt;/P&gt;&lt;P&gt;$CurrentDate = Get-Date -Format 'MM-dd-yyyy_hh-mm-ss'&lt;/P&gt;&lt;P&gt;$logfilelocation= "$location\$($CurrentDate)logfile.txt"&lt;/P&gt;&lt;P&gt;$alltemplatesexportpath="$location\$($CurrentDate)-templateswindows.csv"&lt;/P&gt;&lt;P&gt;$Outputfile = "$location\AllTemplatepatchstatusreport.csv as on dated $($CurrentDate).csv" &lt;/P&gt;&lt;P&gt;$csvFiles = @()&lt;/P&gt;&lt;P&gt;Write-Host "Enter Administrator Credentials for logging into templates" -ForegroundColor Yellow&lt;/P&gt;&lt;P&gt;$cred=Get-Credential&lt;/P&gt;&lt;P&gt;Start-Transcript -Path $logfilelocation -NoClobber -Force -Confirm:$false&lt;/P&gt;&lt;P&gt;$script = @' &lt;/P&gt;&lt;P&gt;$report = @()&lt;/P&gt;&lt;P&gt;$ErrorActionPreference = "SilentlyContinue"&lt;/P&gt;&lt;P&gt;If ($Error) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $Error.Clear()&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;$updatesession=New-Object -ComObject Microsoft.update.session &lt;/P&gt;&lt;P&gt;$Criteria="IsInstalled=0 and Type=Software and IsHidden=0"&lt;/P&gt;&lt;P&gt;$searchresult=$updateSession.CreateupdateSearcher().Search("IsInstalled=0 and Type='Software' and IsHidden=0").Updates &lt;/P&gt;&lt;P&gt;$report = if(-not $searchresult.Count){&lt;/P&gt;&lt;P&gt;New-Object -TypeName PSObject -property @{&lt;/P&gt;&lt;P&gt;KB = ''&lt;/P&gt;&lt;P&gt;InstallStatus = 'There are no applicable updates for this computer.'&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;else{&lt;/P&gt;&lt;P&gt;$pendingdownloads=$searchresult | Where-Object {$_.IsDownloaded -eq $false}&lt;/P&gt;&lt;P&gt;if(($pendingdownloads |Select-Object IsDownloaded).count -ne '0'){&lt;/P&gt;&lt;P&gt;$downloadercall=$updatesession.CreateUpdateDownloader()&lt;/P&gt;&lt;P&gt;$downloadercall.Updates=New-Object -ComObject Microsoft.update.updatecoll&lt;/P&gt;&lt;P&gt;foreach($pendingdownload in $pendingdownloads){&lt;/P&gt;&lt;P&gt;[void]$downloadercall.Updates.add($pendingdownload)&lt;/P&gt;&lt;P&gt;$downloadercall.Download() |Out-Null&lt;/P&gt;&lt;P&gt;[void]$downloadercall.Updates.RemoveAt(0)&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;$updatesession=New-Object -ComObject Microsoft.update.session&lt;/P&gt;&lt;P&gt;$Criteria="IsInstalled=0 and Type=Software and IsHidden=0"&lt;/P&gt;&lt;P&gt;$searchresult=$updateSession.CreateupdateSearcher().Search("IsInstalled=0 and Type='Software' and IsHidden=0").Updates&lt;/P&gt;&lt;P&gt;$downloadedupdates = $searchresult&amp;nbsp; | Where-Object {$_.IsDownloaded -eq $true}&lt;/P&gt;&lt;P&gt;$updatercall=$updatesession.CreateUpdateInstaller()&lt;/P&gt;&lt;P&gt;$updatercall.Updates= New-Object -ComObject Microsoft.update.updatecoll&lt;/P&gt;&lt;P&gt;foreach($singleupdate in $downloadedupdates){&lt;/P&gt;&lt;P&gt;[void]$updatercall.Updates.add($singleupdate)&lt;/P&gt;&lt;P&gt;$installstatus=$updatercall.install()&lt;/P&gt;&lt;P&gt;[void]$updatercall.Updates.RemoveAt(0)&lt;/P&gt;&lt;P&gt;New-Object -TypeName PSObject -property @{&lt;/P&gt;&lt;P&gt;KB = &amp;amp;{$kbnumb=$singleupdate.Title; $kbnumb.Substring($kbnumb.IndexOf("KB")).Trimend(")")}&lt;/P&gt;&lt;P&gt;InstallStatus = &amp;amp;{&lt;/P&gt;&lt;P&gt;if($installstatus.ResultCode -eq '2'){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'KB Installed'&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;elseif($installstatus.ResultCode -eq '3'){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'KB Install Succeeded with errors'&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;elseif($installstatus.ResultCode -eq '4'){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Kb Failed to install'&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;elseif($installstatus.ResultCode -eq '5'){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'KBAborted'&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;elseif (-not $installstatus.ResultCode){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'KB Failed to Download'&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;$report | ConvertTo-Csv -NoTypeInformation&lt;/P&gt;&lt;P&gt;'@&lt;/P&gt;&lt;P&gt;$tasks = @()&lt;/P&gt;&lt;P&gt;$alltemplates=Get-Datacenter&amp;nbsp; | Get-Template&amp;nbsp;&amp;nbsp; |Select-Object @{N='Name';E={$_.Name}},@{N="Portgroup";E={((Get-View -Id $_.ExtensionData.Network).name)}},@{N="vCenter";E={([System.Net.Dns]::GetHostEntry($_.Uid.Split(“:”)[0].Split(“@”)[1])).HostName}}&lt;/P&gt;&lt;P&gt;$alltemplates|Export-Csv -Path $alltemplatesexportpath -NoTypeInformation -NoClobber -UseCulture&lt;/P&gt;&lt;P&gt;foreach($singletemplate in $alltemplates){&lt;/P&gt;&lt;P&gt;Write-Host "Marking Template Name $($singletemplate.Name) to VM"&lt;/P&gt;&lt;P&gt;Set-Template -Template $singletemplate.Name -ToVM -Confirm:$false |fl&lt;/P&gt;&lt;P&gt;$templatevm= Get-VM $singletemplate.Name&lt;/P&gt;&lt;P&gt;if(-not $templatevm.Name){&lt;/P&gt;&lt;P&gt;Write-Host "Setting Template $($singletemplate.Name) to VM Failed Moving to Next Template"&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;else{&lt;/P&gt;&lt;P&gt;Write-Host "Collecting DHCP PortGroup Name for Vlanid 2067 from VMhost $($templatevm.VMHost)"&lt;/P&gt;&lt;P&gt;$dhcpportgroup=Get-VirtualPortGroup -VMHost $templatevm.VMHost |?{$_.ExtensionData.config.DefaultPortConfig.Vlan.VlanId -eq '2067'}&lt;/P&gt;&lt;P&gt;Write-Host "Collecting Network Adapter for $($templatevm.Name)" &lt;/P&gt;&lt;P&gt;$nic=Get-NetworkAdapter -VM $templatevm.Name&lt;/P&gt;&lt;P&gt;Write-Host "Adding Network Adapter to VM $($templatevm.Name) if not Present" &lt;/P&gt;&lt;P&gt;if($nic -eq $null){&lt;/P&gt;&lt;P&gt;New-NetworkAdapter -VM $templatevm.Name -Portgroup $dhcpportgroup -Type Vmxnet3 -StartConnected -Confirm:$false&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;else{&lt;/P&gt;&lt;P&gt;Write-Host "Changing Portgroup to $($dhcpportgroup.Name) to VM $($templatevm.Name)" &lt;/P&gt;&lt;P&gt;Get-NetworkAdapter -VM $templatevm.Name |Set-NetworkAdapter -Portgroup $dhcpportgroup -Confirm:$false |fl&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Write-Host "Starting VM $($templatevm.Name) and wait in loop till GuestOperationsReady is true " &lt;/P&gt;&lt;P&gt;Start-VM -VM $templatevm.Name -Confirm:$false |fl&lt;/P&gt;&lt;P&gt;while($templatevm.ExtensionData.Guest.GuestOperationsReady -ne "True"){&lt;/P&gt;&lt;P&gt;Start-Sleep -Seconds 3&lt;/P&gt;&lt;P&gt;$templatevm.ExtensionData.UpdateViewData("Guest.GuestOperationsReady")&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Write-Host "Updating vmtools on $($templatevm.Name) if they are Outdated"&lt;/P&gt;&lt;P&gt;if($templatevm.ExtensionData.guest.toolsversionstatus -eq 'guestToolsNeedUpgrade'){&lt;/P&gt;&lt;P&gt;$timeoutSeconds = 900&lt;/P&gt;&lt;P&gt;$start = (Get-Date)&lt;/P&gt;&lt;P&gt;$task = Get-View -Id (Update-Tools -VM $templatevm.Name -NoReboot&amp;nbsp; -RunAsync).Id&lt;/P&gt;&lt;P&gt;while((New-TimeSpan -Start $start -End (Get-Date)).TotalSeconds -lt $timeoutSeconds -and &lt;/P&gt;&lt;P&gt;($task.Info.State -eq [VMware.Vim.TaskInfoState]::running -or&lt;/P&gt;&lt;P&gt;$task.Info.State -eq [VMware.Vim.TaskInfoState]::queued)){&lt;/P&gt;&lt;P&gt;Sleep 5&lt;/P&gt;&lt;P&gt;$task.UpdateViewData()&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;if($task.Info.State -eq [VMware.Vim.TaskInfoState]::running){&lt;/P&gt;&lt;P&gt;$task.CancelTask()&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;elseif($task.Info.State -eq [VMware.Vim.TaskInfoState]::error){&lt;/P&gt;&lt;P&gt;Write-Error "Update Tools failed"&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Write-Host "Waiting for GuestOperationsReady to be true on $($templatevm.Name)"&lt;/P&gt;&lt;P&gt;$templatevm.ExtensionData.UpdateViewData("Guest.GuestOperationsReady")&lt;/P&gt;&lt;P&gt;while($templatevm.ExtensionData.Guest.GuestOperationsReady -ne "True"){&lt;/P&gt;&lt;P&gt;Start-Sleep -Seconds 3&lt;/P&gt;&lt;P&gt;$templatevm.ExtensionData.UpdateViewData("Guest.GuestOperationsReady")&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Write-Host "Performing Invoke Operation on $($templatevm.Name)"&lt;/P&gt;&lt;P&gt;$sInvoke = @{&lt;/P&gt;&lt;P&gt;VM&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = $templatevm.Name&lt;/P&gt;&lt;P&gt;GuestCredential=$cred&lt;/P&gt;&lt;P&gt;ScriptText&amp;nbsp;&amp;nbsp;&amp;nbsp; = $script&lt;/P&gt;&lt;P&gt;ScriptType&amp;nbsp;&amp;nbsp;&amp;nbsp; = 'Powershell'&lt;/P&gt;&lt;P&gt;RunAsync&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = $true&lt;/P&gt;&lt;P&gt;Confirm&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = $false&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;$tasks += @{&lt;/P&gt;&lt;P&gt;VM = $templatevm.Name&lt;/P&gt;&lt;P&gt;Task = Invoke-VMScript @sInvoke&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Write-Host "Invoke Operation is performed on all the templates and waiting for results to be collected"&lt;/P&gt;&lt;P&gt;while($tasks.Task.State -contains 'Running'){&lt;/P&gt;&lt;P&gt;sleep 2&lt;/P&gt;&lt;P&gt;Write-Host "waiting on Invoke Operation to Complete" -ForegroundColor Yellow&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Write-Host "Passing tasks information to foreach loop"&lt;/P&gt;&lt;P&gt;$tasks |ForEach-Object -Process {&lt;/P&gt;&lt;P&gt;$vm=Get-VM -Name $_.VM&lt;/P&gt;&lt;P&gt;Write-Host "Stopping VM $($vm.Name) to Apply windows updates"&lt;/P&gt;&lt;P&gt;Stop-VMGuest -VM $vm.Name -Confirm:$false&lt;/P&gt;&lt;P&gt;while($vm.ExtensionData.Runtime.PowerState -ne 'poweredOff'){&lt;/P&gt;&lt;P&gt;Start-Sleep -Seconds 1&lt;/P&gt;&lt;P&gt;$vm.ExtensionData.UpdateViewData("Runtime.Powerstate")&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Write-Host "Starting back the VM $($vm.Name) after applying updates"&lt;/P&gt;&lt;P&gt;Start-VM -VM $vm.Name -Confirm:$false&lt;/P&gt;&lt;P&gt;$vm.ExtensionData.UpdateViewData("Guest.GuestOperationsReady")&lt;/P&gt;&lt;P&gt;while($vm.ExtensionData.Guest.GuestOperationsReady -ne "True"){&lt;/P&gt;&lt;P&gt;Start-Sleep -Seconds 1&lt;/P&gt;&lt;P&gt;$vm.ExtensionData.UpdateViewData("Guest.GuestOperationsReady")&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Write-Host "Performing Invoke operation on VM $($vm.Name) to check if all updates are installed"&lt;/P&gt;&lt;P&gt;$updatescheckscript=@'&lt;/P&gt;&lt;P&gt;$updateObject = New-Object -ComObject Microsoft.Update.Session&lt;/P&gt;&lt;P&gt;$updateSearcher = $updateObject.CreateUpdateSearcher()&lt;/P&gt;&lt;P&gt;$searchResults = $updateSearcher.Search("IsInstalled=0")&lt;/P&gt;&lt;P&gt;$timeoutValue = 1200&lt;/P&gt;&lt;P&gt;$startTime = Get-Date&lt;/P&gt;&lt;P&gt;while($searchResults.Updates.Count -ne '0' -and (New-TimeSpan -Start $startTime -End (Get-Date)).TotalSeconds -lt $timeoutValue){&lt;/P&gt;&lt;P&gt;Start-Sleep 1&lt;/P&gt;&lt;P&gt;$searchResults.Updates.Count&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;if((New-TimeSpan -Start $startTime -End (Get-Date)).TotalSeconds -ge $timeoutValue) {&lt;/P&gt;&lt;P&gt;'windows update completed Partially'&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;else{&lt;/P&gt;&lt;P&gt;'windows update completed sucessfully'&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;'@&lt;/P&gt;&lt;P&gt;$sInvoke = @{&lt;/P&gt;&lt;P&gt;VM&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = $vm.Name&lt;/P&gt;&lt;P&gt;GuestCredential=$cred&lt;/P&gt;&lt;P&gt;ScriptText&amp;nbsp;&amp;nbsp;&amp;nbsp; = $updatescheckscript&lt;/P&gt;&lt;P&gt;ScriptType&amp;nbsp;&amp;nbsp;&amp;nbsp; = 'Powershell'&lt;/P&gt;&lt;P&gt;ErrorAction&amp;nbsp;&amp;nbsp; = 'SilentlyContinue'&lt;/P&gt;&lt;P&gt;Confirm&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = $false&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;$invokeresult=Invoke-VMScript @sInvoke&lt;/P&gt;&lt;P&gt;Write-Host "Result of invoke operation on VM $($vm.Name)"&lt;/P&gt;&lt;P&gt;Write-Host $invokeresult.ScriptOutput&lt;/P&gt;&lt;P&gt;Write-Host "Performing Stop operation on VM $($vm.Name) before converting to Template"&lt;/P&gt;&lt;P&gt;$maxCount = 3&lt;/P&gt;&lt;P&gt;$count = 0&lt;/P&gt;&lt;P&gt;while($count -lt $maxCount -and $vm.PowerState -ne 'PoweredOff' ){&lt;/P&gt;&lt;P&gt;Stop-VMGuest -VM $vm.Name -Confirm:$false&lt;/P&gt;&lt;P&gt;$count++&lt;/P&gt;&lt;P&gt;Sleep 300&lt;/P&gt;&lt;P&gt;$vm = Get-VM -Name $vm.Name&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;if($vm.PowerState -ne 'PoweredOff'){&lt;/P&gt;&lt;P&gt;Stop-VM -VM $vm -Confirm:$false&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Write-Host "Updating report to csv"&lt;/P&gt;&lt;P&gt;if($_.Task.State -eq 'Success'){&lt;/P&gt;&lt;P&gt;$_.Task.Result.Scriptoutput | ConvertFrom-Csv |&lt;/P&gt;&lt;P&gt;Add-Member -MemberType NoteProperty -Name VM -Value $_.VM.Name -PassThru |&lt;/P&gt;&lt;P&gt;Add-Member -MemberType NoteProperty -Name State -Value $_.Task.State -PassThru&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;else{&lt;/P&gt;&lt;P&gt;New-Object -TypeName PSObject -Property @{&lt;/P&gt;&lt;P&gt;VM = $_.VM.Name&lt;/P&gt;&lt;P&gt;KB = ''&lt;/P&gt;&lt;P&gt;InstallStatus = ''&lt;/P&gt;&lt;P&gt;State = $_.Task.State&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;} | Select VM,State,KB,InstallStatus |Export-Csv -Path $Outputfile -NoTypeInformation -NoClobber -UseCulture&lt;/P&gt;&lt;P&gt;Write-Host "Saved results to csv file"&lt;/P&gt;&lt;P&gt;$csvFiles += $Outputfile&lt;/P&gt;&lt;P&gt;Write-Host "Converting Back to templates"&lt;/P&gt;&lt;P&gt;$alltemplates |ForEach-Object -Process {&lt;/P&gt;&lt;P&gt;Get-NetworkAdapter -VM $_.name |Set-NetworkAdapter -NetworkName $_.Portgroup -Confirm:$false&lt;/P&gt;&lt;P&gt;Set-VM -VM $_.Name -ToTemplate -Confirm:$false&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Stop-Transcript&lt;/P&gt;&lt;P&gt;$csvFiles+=$logfilelocation&lt;/P&gt;&lt;P&gt;$csvFiles+=$alltemplatesexportpath&lt;/P&gt;&lt;P&gt;Send-MailMessage -From "" -To "" -Subject "Template Patching Info" ` -Body "The attachment contains templates patching status after script execution" ` -Attachments $csvFiles -SmtpServer ''&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Aug 2020 09:37:58 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/all-windows-templates-patching-in-a-datacenter/m-p/2289988#M80540</guid>
      <dc:creator>vin01</dc:creator>
      <dc:date>2020-08-31T09:37:58Z</dc:date>
    </item>
    <item>
      <title>Re: Wait for vm to fully start up until windows is applying updates</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Wait-for-vm-to-fully-start-up-until-windows-is-applying-updates/m-p/2314305#M83151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Its working. I used as below as scripttext in invoke-vmscript.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_15988642792708761 jive_text_macro" data-renderedposition="49.60000228881836_8_1232_240" jivemacro_uid="_15988642792708761" modifiedtitle="true"&gt;&lt;P&gt;$updateObject = New-Object -ComObject Microsoft.Update.Session&lt;/P&gt;&lt;P&gt;$updateSearcher = $updateObject.CreateUpdateSearcher()&lt;/P&gt;&lt;P&gt;$searchResults = $updateSearcher.Search("IsInstalled=0")&lt;/P&gt;&lt;P&gt;$timeoutValue = 1200&lt;/P&gt;&lt;P&gt;$startTime = Get-Date&lt;/P&gt;&lt;P&gt;while($searchResults.Updates.Count -ne '0' -and (New-TimeSpan -Start $startTime -End (Get-Date)).TotalSeconds -lt $timeoutValue){&lt;/P&gt;&lt;P&gt;Start-Sleep 1&lt;/P&gt;&lt;P&gt;$searchResults.Updates.Count&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;if((New-TimeSpan -Start $startTime -End (Get-Date)).TotalSeconds -ge $timeoutValue) {&lt;/P&gt;&lt;P&gt;'windows update completed Partially'&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;else{&lt;/P&gt;&lt;P&gt;'windows update completed sucessfully'&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Aug 2020 08:58:19 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Wait-for-vm-to-fully-start-up-until-windows-is-applying-updates/m-p/2314305#M83151</guid>
      <dc:creator>vin01</dc:creator>
      <dc:date>2020-08-31T08:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: Wait for vm to fully start up until windows is applying updates</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Wait-for-vm-to-fully-start-up-until-windows-is-applying-updates/m-p/2314303#M83149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am sorry if my question is not clear. Let me explain again.&lt;/P&gt;&lt;P&gt;I am not trying to check updates are installed or not by using invoke operation. I just rebooting a set of vms to apply updates once done then powering off the VM.&lt;/P&gt;&lt;P&gt;When&amp;nbsp; 3rd line of the script is executed the VM will shutdown and in console I can see updating windows don't shutdown. So my while condition will wait till powerstate becomes poweredOff --(Till here working fine)&lt;/P&gt;&lt;P&gt;When 9th line of the script is executed the VM will power on and when it is booting up. On the console it says windows is applying the updates but the Guest.GuestOperationsReady property shows true so the script will not wait in whileloop as expected and it will go to 16th line to stop the VM. But actual vm is still applying updates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So any other option instead of checking Guest.GuestOperationsReady property after line 9 (Something like if vm console shows ctrl+alt+del screen) then go to line 16th to stop the vm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_15976666970917955" data-renderedposition="216_8_1232_352" jivemacro_uid="_15976666970917955"&gt;&lt;P&gt;foreach($vm in (Get-VM Test01,Test02)){&lt;/P&gt;&lt;P&gt;Write-Host "Stopping VM $($vm.Name) to Apply windows updates"&lt;/P&gt;&lt;P&gt;Stop-VMGuest -VM $vm.Name -Confirm:$false&lt;/P&gt;&lt;P&gt;while($vm.ExtensionData.Runtime.PowerState -ne 'poweredOff'){&lt;/P&gt;&lt;P&gt;Start-Sleep -Seconds 1&lt;/P&gt;&lt;P&gt;$vm.ExtensionData.UpdateViewData("Runtime.Powerstate")&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Write-Host "Starting back the VM $($vm.Name) after applying updates"&lt;/P&gt;&lt;P&gt;Start-VM -VM $vm.Name -Confirm:$false&lt;/P&gt;&lt;P&gt;$vm.ExtensionData.UpdateViewData("Guest.GuestOperationsReady")&lt;/P&gt;&lt;P&gt;while($vm.ExtensionData.Guest.GuestOperationsReady -ne "True"){&lt;/P&gt;&lt;P&gt;Start-Sleep -Seconds 1&lt;/P&gt;&lt;P&gt;$vm.ExtensionData.UpdateViewData("Guest.GuestOperationsReady")&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Write-Host "Performing Final Stop operation on VM $($vm.Name)"&lt;/P&gt;&lt;P&gt;Stop-VMGuest -VM $vm.Name -Confirm:$false&lt;/P&gt;&lt;P&gt;$vm.ExtensionData.UpdateViewData("Runtime.PowerState")&lt;/P&gt;&lt;P&gt;while($vm.ExtensionData.Runtime.PowerState -eq 'poweredOn'){&lt;/P&gt;&lt;P&gt;Start-Sleep -Seconds 1&lt;/P&gt;&lt;P&gt;$vm.ExtensionData.UpdateViewData("Runtime.Powerstate")&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Aug 2020 12:43:55 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Wait-for-vm-to-fully-start-up-until-windows-is-applying-updates/m-p/2314303#M83149</guid>
      <dc:creator>vin01</dc:creator>
      <dc:date>2020-08-17T12:43:55Z</dc:date>
    </item>
    <item>
      <title>Wait for vm to fully start up until windows is applying updates</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Wait-for-vm-to-fully-start-up-until-windows-is-applying-updates/m-p/2314301#M83147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With the below script I am trying to perform shutdown vm and apply windows updates and power on it and wait till windows updates are fully applied and then poweroff the machine.&lt;/P&gt;&lt;P&gt;Steps as below:&lt;/P&gt;&lt;P&gt;1.Do guest shutdown for the vm which is $vm variable and wait till powerstate becomes poweredOff.&lt;/P&gt;&lt;P&gt;2. Start back the vm and wait till Guest.GuestOperationsReady becomes True&lt;/P&gt;&lt;P&gt;3. Then finally poweroff the vm using Stop-VMGuest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here in step 2&amp;nbsp; when I start the vm it is applying the windows updates. However the Guest.GuestOperationsReady state shows True so its not waiting for the guest to completely startup in a whileloop. It just moved to step 3 and the windows updates are not applying as expected. Is there any way to wait till we see ctrl+alt+del screen in windows and move to step 3.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_15976612305687207 jive_text_macro" data-renderedposition="195.1999969482422_8_1232_352" jivemacro_uid="_15976612305687207" modifiedtitle="true"&gt;&lt;P&gt;foreach($vm in (Get-VM Test01,Test02)){&lt;/P&gt;&lt;P&gt;Write-Host "Stopping VM $($vm.Name) to Apply windows updates"&lt;/P&gt;&lt;P&gt;Stop-VMGuest -VM $vm.Name -Confirm:$false&lt;/P&gt;&lt;P&gt;while($vm.ExtensionData.Runtime.PowerState -ne 'poweredOff'){&lt;/P&gt;&lt;P&gt;Start-Sleep -Seconds 1&lt;/P&gt;&lt;P&gt;$vm.ExtensionData.UpdateViewData("Runtime.Powerstate")&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Write-Host "Starting back the VM $($vm.Name) after applying updates"&lt;/P&gt;&lt;P&gt;Start-VM -VM $vm.Name -Confirm:$false&lt;/P&gt;&lt;P&gt;$vm.ExtensionData.UpdateViewData("Guest.GuestOperationsReady")&lt;/P&gt;&lt;P&gt;while($vm.ExtensionData.Guest.GuestOperationsReady -ne "True"){&lt;/P&gt;&lt;P&gt;Start-Sleep -Seconds 1&lt;/P&gt;&lt;P&gt;$vm.ExtensionData.UpdateViewData("Guest.GuestOperationsReady")&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Write-Host "Performing Final Stop operation on VM $($vm.Name)"&lt;/P&gt;&lt;P&gt;Stop-VMGuest -VM $vm.Name -Confirm:$false&lt;/P&gt;&lt;P&gt;$vm.ExtensionData.UpdateViewData("Runtime.PowerState")&lt;/P&gt;&lt;P&gt;while($vm.ExtensionData.Runtime.PowerState -eq 'poweredOn'){&lt;/P&gt;&lt;P&gt;Start-Sleep -Seconds 1&lt;/P&gt;&lt;P&gt;$vm.ExtensionData.UpdateViewData("Runtime.Powerstate")&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Aug 2020 10:49:28 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Wait-for-vm-to-fully-start-up-until-windows-is-applying-updates/m-p/2314301#M83147</guid>
      <dc:creator>vin01</dc:creator>
      <dc:date>2020-08-17T10:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to write invoke-vmscript output which contains multiple lines</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/how-to-write-invoke-vmscript-output-which-contains-multiple/m-p/2306821#M82419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah now its working. How do I export this results to csv file. Is it possible to keep the output in array. something like below so that i can easily export for all the vms&lt;/P&gt;&lt;P&gt;$finaloutput=@()&lt;/P&gt;&lt;P&gt;$finaloutput |Export-Csv&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Aug 2020 09:10:45 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/how-to-write-invoke-vmscript-output-which-contains-multiple/m-p/2306821#M82419</guid>
      <dc:creator>vin01</dc:creator>
      <dc:date>2020-08-11T09:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to write invoke-vmscript output which contains multiple lines</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/how-to-write-invoke-vmscript-output-which-contains-multiple/m-p/2306819#M82417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One Last Thing. I don't want the VMName from inside the guestos(&lt;SPAN style="color: #448c27; font-family: proxima-nova, Arial, sans-serif; background-color: #f0fade;"&gt;VM = $env:COMPUTERNAME)&amp;nbsp; &lt;/SPAN&gt;because for few vms the displayname in the vcenter is different when compare to the vm name inside the guest os. Can it be possible to write only name which is in vcenter.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Aug 2020 07:05:46 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/how-to-write-invoke-vmscript-output-which-contains-multiple/m-p/2306819#M82417</guid>
      <dc:creator>vin01</dc:creator>
      <dc:date>2020-08-11T07:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: how to write invoke-vmscript output which contains multiple lines</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/how-to-write-invoke-vmscript-output-which-contains-multiple/m-p/2306817#M82415</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;I'm not sure why insist on doing the ConvertFrom-Csv for each property separately.&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;Yeah That's my mistake. I am not clear on how to write the kb results when they are more then one and if no updates are available on the computer. Can you pls correct the above code or rewrite if they are more then one kb or &lt;SPAN style="color: #666666; font-family: proxima-nova, Arial, sans-serif;"&gt;no updates are available. &lt;/SPAN&gt;something as below&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;&lt;STRONG&gt;VM : VM01&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;State: Success&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;Error:&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;&lt;STRONG&gt;KB: KB4565628&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;Installstatus: KBInstalled&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;&lt;STRONG&gt;VM : VM01&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;State: Success&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;Error:&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;&lt;STRONG&gt;KB: KB4565511&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;Installstatus: KBInstalled&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;&lt;STRONG&gt;VM : VM02&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;State: Success&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;Error:&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;KB: &lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;Installstatus: There are no applicable updates for this computer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;&lt;STRONG&gt;VM : VM03&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;State: Success&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;Error:&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;&lt;STRONG&gt;KB: KB4567511&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;&lt;STRONG&gt;Installstatus: Kb Failed to install&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Aug 2020 15:32:11 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/how-to-write-invoke-vmscript-output-which-contains-multiple/m-p/2306817#M82415</guid>
      <dc:creator>vin01</dc:creator>
      <dc:date>2020-08-10T15:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to write invoke-vmscript output which contains multiple lines</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/how-to-write-invoke-vmscript-output-which-contains-multiple/m-p/2306815#M82413</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is what I have passed inside the guestos. Actually $task.Task.Result.ScriptOutput contains multiple values for each vm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_15970703458687916 jive_text_macro" data-renderedposition="49.60000228881836_8_1232_1104" jivemacro_uid="_15970703458687916" modifiedtitle="true"&gt;&lt;P&gt;$script=@'&lt;/P&gt;&lt;P&gt;$results=@()&lt;/P&gt;&lt;P&gt;$ErrorActionPreference = "SilentlyContinue"&lt;/P&gt;&lt;P&gt;If ($Error) {&lt;/P&gt;&lt;P&gt;$Error.Clear()&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;$updatesession=New-Object -ComObject Microsoft.update.session &lt;/P&gt;&lt;P&gt;$Criteria="IsInstalled=0 and Type=Software and IsHidden=0"&lt;/P&gt;&lt;P&gt;$searchresult=$updateSession.CreateupdateSearcher().Search("IsInstalled=0 and Type='Software' and IsHidden=0").Updates &lt;/P&gt;&lt;P&gt;if(-not $searchresult.Count){&lt;/P&gt;&lt;P&gt;$results+="There are no applicable updates for this computer."&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;else{&lt;/P&gt;&lt;P&gt;$pendingdownloads=$searchresult | Where-Object {$_.IsDownloaded -eq $false}&lt;/P&gt;&lt;P&gt;if(($pendingdownloads |Select-Object IsDownloaded).count -ne '0'){&lt;/P&gt;&lt;P&gt;$downloadercall=$updatesession.CreateUpdateDownloader()&lt;/P&gt;&lt;P&gt;$downloadercall.Updates=New-Object -ComObject Microsoft.update.updatecoll&lt;/P&gt;&lt;P&gt;foreach($pendingdownload in $pendingdownloads){&lt;/P&gt;&lt;P&gt;[void]$downloadercall.Updates.add($pendingdownload)&lt;/P&gt;&lt;P&gt;$downloadercall.Download() |Out-Null&lt;/P&gt;&lt;P&gt;[void]$downloadercall.Updates.RemoveAt(0)&lt;/P&gt;&lt;P&gt;}}&lt;/P&gt;&lt;P&gt;$updatesession=New-Object -ComObject Microsoft.update.session&lt;/P&gt;&lt;P&gt;$Criteria="IsInstalled=0 and Type=Software and IsHidden=0"&lt;/P&gt;&lt;P&gt;$searchresult=$updateSession.CreateupdateSearcher().Search("IsInstalled=0 and Type='Software' and IsHidden=0").Updates&lt;/P&gt;&lt;P&gt;$downloadedupdates = $searchresult&amp;nbsp; | Where-Object {$_.IsDownloaded -eq $true}&lt;/P&gt;&lt;P&gt;$updatercall=$updatesession.CreateUpdateInstaller()&lt;/P&gt;&lt;P&gt;$updatercall.Updates= New-Object -ComObject Microsoft.update.updatecoll&lt;/P&gt;&lt;P&gt;$results+=foreach($singleupdate in $downloadedupdates){&lt;/P&gt;&lt;P&gt;[void]$updatercall.Updates.add($singleupdate)&lt;/P&gt;&lt;P&gt;$installstatus=$updatercall.install()&lt;/P&gt;&lt;P&gt;[void]$updatercall.Updates.RemoveAt(0)&lt;/P&gt;&lt;P&gt;''|Select-Object @{N="KB";E={$kbnumb=$singleupdate.Title;$kbnumb.Substring($kbnumb.IndexOf("KB")).Trimend(")")}},@{N="Installstatus";E={if($installstatus.ResultCode -eq '2'){&lt;/P&gt;&lt;P&gt;'KBInstalled'}&lt;/P&gt;&lt;P&gt;elseif($installstatus.ResultCode -eq '3'){&lt;/P&gt;&lt;P&gt;'KBInstall Succeeded with errors'}&lt;/P&gt;&lt;P&gt;elseif($installstatus.ResultCode -eq '4'){&lt;/P&gt;&lt;P&gt;'Kb Failed to install'}&lt;/P&gt;&lt;P&gt;elseif($installstatus.ResultCode -eq '5'){&lt;/P&gt;&lt;P&gt;'KBAborted'}}}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;$results |ConvertTo-Csv -NoTypeInformation&lt;/P&gt;&lt;P&gt;'@&lt;/P&gt;&lt;P&gt;$templatevm=Get-VM 'TestVM01'&lt;/P&gt;&lt;P&gt;$sInvoke = @{&lt;/P&gt;&lt;P&gt;VM&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = $templatevm.Name&lt;/P&gt;&lt;P&gt;GuestUser&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 'administrator'&lt;/P&gt;&lt;P&gt;GuestPassword = 'password'&lt;/P&gt;&lt;P&gt;ScriptText&amp;nbsp;&amp;nbsp;&amp;nbsp; = $script&lt;/P&gt;&lt;P&gt;ScriptType&amp;nbsp;&amp;nbsp;&amp;nbsp; = 'Powershell'&lt;/P&gt;&lt;P&gt;RunAsync&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = $true&lt;/P&gt;&lt;P&gt;Confirm&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = $false&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;$tasks += @{&lt;/P&gt;&lt;P&gt;VM = $templatevm.Name&lt;/P&gt;&lt;P&gt;Task = Invoke-VMScript @sInvoke&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Write-Host "Invoke Operation is performed on all the templates and waiting for results to be collected"&lt;/P&gt;&lt;P&gt;while($tasks.Task.State -contains 'Running'){&lt;/P&gt;&lt;P&gt;sleep 2&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;foreach ($task in $tasks) {&lt;/P&gt;&lt;P&gt;$task | Select @{N='VM';E={$_.VM}},&lt;/P&gt;&lt;P&gt;@{N='State';E={$_.Task.State}},&lt;/P&gt;&lt;P&gt;@{N='Error';E={$_.Task.TerminatingError.Message}},&lt;/P&gt;&lt;P&gt;#@{N ='KB'; E={(($_.Task.Result.ScriptOutput |ConvertFrom-Csv).KB)}},&lt;/P&gt;&lt;P&gt;#@{N ='Installstatus'; E={(($_.Task.Result.ScriptOutput |ConvertFrom-Csv).Installstatus)}}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the actual output of the single VM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://communities.vmware.com/t5/image/serverpage/image-id/22198iB18443D8CD0FDF30/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am expecting Output like this for single VM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;VM : VM01&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;State: Success&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;Error:&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;KB: KB4565628&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;Installstatus: KBInstalled&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;VM : VM01&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;State: Success&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;Error:&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;KB: KB4565511&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;Installstatus: KBInstalled&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Aug 2020 14:45:15 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/how-to-write-invoke-vmscript-output-which-contains-multiple/m-p/2306815#M82413</guid>
      <dc:creator>vin01</dc:creator>
      <dc:date>2020-08-10T14:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: how to write invoke-vmscript output which contains multiple lines</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/how-to-write-invoke-vmscript-output-which-contains-multiple/m-p/2306813#M82411</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;After using ConvertTo-Csv I can able to get the output in correct way but how to write the output foreach kb in csv.&lt;/P&gt;&lt;P&gt;Right now I getting output as below:&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="_jivemacro_uid_15970640405568526 jive_macro_code jive_text_macro" data-renderedposition="49.60000228881836_8_1232_112" jivemacro_uid="_15970640405568526"&gt;&lt;P&gt;foreach ($task in $tasks) {&lt;/P&gt;&lt;P&gt;$task | Select @{N='VM';E={$_.VM}},&lt;/P&gt;&lt;P&gt;@{N='State';E={$_.Task.State}},&lt;/P&gt;&lt;P&gt;@{N='Error';E={$_.Task.TerminatingError.Message}},&lt;/P&gt;&lt;P&gt;@{N ='KB'; E={(($_.Task.Result.ScriptOutput |ConvertFrom-Csv).KB)}},&lt;/P&gt;&lt;P&gt;@{N ='Installstatus'; E={(($_.Task.Result.ScriptOutput |ConvertFrom-Csv).Installstatus)}}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;output:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://communities.vmware.com/t5/image/serverpage/image-id/22197iB025F54FE0F8527A/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;--------------------------------------&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Expecting output as below:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;VM : VM01&lt;/P&gt;&lt;P&gt;State: Success&lt;/P&gt;&lt;P&gt;Error:&lt;/P&gt;&lt;P&gt;KB: KB4565628&lt;/P&gt;&lt;P&gt;Installstatus: KBInstalled&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;VM : VM01&lt;/P&gt;&lt;P&gt;State: Success&lt;/P&gt;&lt;P&gt;Error:&lt;/P&gt;&lt;P&gt;KB: KB4565511&lt;/P&gt;&lt;P&gt;Installstatus: KBInstalled&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Aug 2020 12:58:24 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/how-to-write-invoke-vmscript-output-which-contains-multiple/m-p/2306813#M82411</guid>
      <dc:creator>vin01</dc:creator>
      <dc:date>2020-08-10T12:58:24Z</dc:date>
    </item>
    <item>
      <title>how to write invoke-vmscript output which contains multiple lines</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/how-to-write-invoke-vmscript-output-which-contains-multiple/m-p/2306811#M82409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When I execute the code which is in &lt;STRONG&gt;$script&lt;/STRONG&gt;&amp;nbsp; inside a guest os I can get the expected results but using Invoke-VMScript the results are not writing properly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="_jivemacro_uid_15970568707499724 jive_macro_code jive_text_macro" data-renderedposition="49.60000228881836_8_1232_1104" jivemacro_uid="_15970568707499724"&gt;&lt;P&gt;$script=@'&lt;/P&gt;&lt;P&gt;$results=@()&lt;/P&gt;&lt;P&gt;$ErrorActionPreference = "SilentlyContinue"&lt;/P&gt;&lt;P&gt;If ($Error) {&lt;/P&gt;&lt;P&gt;$Error.Clear()&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;$updatesession=New-Object -ComObject Microsoft.update.session &lt;/P&gt;&lt;P&gt;$Criteria="IsInstalled=0 and Type=Software and IsHidden=0"&lt;/P&gt;&lt;P&gt;$searchresult=$updateSession.CreateupdateSearcher().Search("IsInstalled=0 and Type='Software' and IsHidden=0").Updates &lt;/P&gt;&lt;P&gt;if(-not $searchresult.Count){&lt;/P&gt;&lt;P&gt;$results+="There are no applicable updates for this computer."&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;else{&lt;/P&gt;&lt;P&gt;$pendingdownloads=$searchresult | Where-Object {$_.IsDownloaded -eq $false}&lt;/P&gt;&lt;P&gt;if(($pendingdownloads |Select-Object IsDownloaded).count -ne '0'){&lt;/P&gt;&lt;P&gt;$downloadercall=$updatesession.CreateUpdateDownloader()&lt;/P&gt;&lt;P&gt;$downloadercall.Updates=New-Object -ComObject Microsoft.update.updatecoll&lt;/P&gt;&lt;P&gt;foreach($pendingdownload in $pendingdownloads){&lt;/P&gt;&lt;P&gt;[void]$downloadercall.Updates.add($pendingdownload)&lt;/P&gt;&lt;P&gt;$downloadercall.Download() |Out-Null&lt;/P&gt;&lt;P&gt;[void]$downloadercall.Updates.RemoveAt(0)&lt;/P&gt;&lt;P&gt;}}&lt;/P&gt;&lt;P&gt;$updatesession=New-Object -ComObject Microsoft.update.session&lt;/P&gt;&lt;P&gt;$Criteria="IsInstalled=0 and Type=Software and IsHidden=0"&lt;/P&gt;&lt;P&gt;$searchresult=$updateSession.CreateupdateSearcher().Search("IsInstalled=0 and Type='Software' and IsHidden=0").Updates&lt;/P&gt;&lt;P&gt;$downloadedupdates = $searchresult&amp;nbsp; | Where-Object {$_.IsDownloaded -eq $true}&lt;/P&gt;&lt;P&gt;$updatercall=$updatesession.CreateUpdateInstaller()&lt;/P&gt;&lt;P&gt;$updatercall.Updates= New-Object -ComObject Microsoft.update.updatecoll&lt;/P&gt;&lt;P&gt;$results+=foreach($singleupdate in $downloadedupdates){&lt;/P&gt;&lt;P&gt;[void]$updatercall.Updates.add($singleupdate)&lt;/P&gt;&lt;P&gt;$installstatus=$updatercall.install()&lt;/P&gt;&lt;P&gt;[void]$updatercall.Updates.RemoveAt(0)&lt;/P&gt;&lt;P&gt;''|Select-Object @{N="KB";E={$kbnumb=$singleupdate.Title;$kbnumb.Substring($kbnumb.IndexOf("KB")).Trimend(")")}},@{N="Installstatus";E={if($installstatus.ResultCode -eq '2'){&lt;/P&gt;&lt;P&gt;'KBInstalled'}&lt;/P&gt;&lt;P&gt;elseif($installstatus.ResultCode -eq '3'){&lt;/P&gt;&lt;P&gt;'KBInstall Succeeded with errors'}&lt;/P&gt;&lt;P&gt;elseif($installstatus.ResultCode -eq '4'){&lt;/P&gt;&lt;P&gt;'Kb Failed to install'}&lt;/P&gt;&lt;P&gt;elseif($installstatus.ResultCode -eq '5'){&lt;/P&gt;&lt;P&gt;'KBAborted'}}}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;$results&lt;/P&gt;&lt;P&gt;'@&lt;/P&gt;&lt;P&gt;foreach($templatevm in (Get-VM "*Template*")){&lt;/P&gt;&lt;P&gt;$sInvoke = @{&lt;/P&gt;&lt;P&gt;VM&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = $templatevm.Name&lt;/P&gt;&lt;P&gt;GuestUser&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 'administrator'&lt;/P&gt;&lt;P&gt;GuestPassword = 'password'&lt;/P&gt;&lt;P&gt;ScriptText&amp;nbsp;&amp;nbsp;&amp;nbsp; = $script&lt;/P&gt;&lt;P&gt;ScriptType&amp;nbsp;&amp;nbsp;&amp;nbsp; = 'Powershell'&lt;/P&gt;&lt;P&gt;RunAsync&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = $true&lt;/P&gt;&lt;P&gt;Confirm&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = $false&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;$tasks += @{&lt;/P&gt;&lt;P&gt;VM = $templatevm.Name&lt;/P&gt;&lt;P&gt;Task = Invoke-VMScript @sInvoke&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Write-Host "Invoke Operation is performed on all the templates and waiting for results to be collected"&lt;/P&gt;&lt;P&gt;while($tasks.Task.State -contains 'Running'){&lt;/P&gt;&lt;P&gt;sleep 2&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;foreach ($task in $tasks) {&lt;/P&gt;&lt;P&gt;$task | Select @{N='VM';E={$_.VM}},&lt;/P&gt;&lt;P&gt;@{N='State';E={$_.Task.State}},&lt;/P&gt;&lt;P&gt;@{N='Error';E={$_.Task.TerminatingError.Message}},&lt;/P&gt;&lt;P&gt;@{N ='Result'; E={$_.Task.Result.ScriptOutput.Split("`n") |Where-Object { $_ -ne '' } | %{$_.Trim("`r`n")}}}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Result of &lt;STRONG&gt;$script&lt;/STRONG&gt; inside the guest OS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://communities.vmware.com/t5/image/serverpage/image-id/22179i2B7F3DE55256A0F4/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But when I executed using invoke-vmscript the result is below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_0.png"&gt;&lt;img src="https://communities.vmware.com/t5/image/serverpage/image-id/22196iF46FA829334B2CBE/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_0.png" alt="pastedImage_0.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Aug 2020 10:55:12 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/how-to-write-invoke-vmscript-output-which-contains-multiple/m-p/2306811#M82409</guid>
      <dc:creator>vin01</dc:creator>
      <dc:date>2020-08-10T10:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: Failed to cancel update tools task and stop-vmguest max tries failed</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Failed-to-cancel-update-tools-task-and-stop-vmguest-max-tries/m-p/2292681#M80857</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry for late response. It worked after replacing the condition in where-clause.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Aug 2020 10:11:12 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Failed-to-cancel-update-tools-task-and-stop-vmguest-max-tries/m-p/2292681#M80857</guid>
      <dc:creator>vin01</dc:creator>
      <dc:date>2020-08-10T10:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: Failed to cancel update tools task and stop-vmguest max tries failed</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Failed-to-cancel-update-tools-task-and-stop-vmguest-max-tries/m-p/2292679#M80855</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One more thing I’m suspected after looking the below lines from transcript file. &lt;/P&gt;&lt;P&gt;VMware tools update task is completed and script is not going to next line until timeout is completed. which I showed on my previous reply with screenshot. So might be the task object got deleted. And it’s still trying to find it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;The object 'vim.Task:task-975776' has already been deleted or&lt;/P&gt;&lt;P style="margin: 2px; font-family: proxima-nova, Arial, sans-serif; color: #666666;"&gt;has not been completely created"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jul 2020 16:36:12 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Failed-to-cancel-update-tools-task-and-stop-vmguest-max-tries/m-p/2292679#M80855</guid>
      <dc:creator>vin01</dc:creator>
      <dc:date>2020-07-23T16:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: Failed to cancel update tools task and stop-vmguest max tries failed</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Failed-to-cancel-update-tools-task-and-stop-vmguest-max-tries/m-p/2292678#M80854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok Thanks LucD.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jul 2020 11:15:52 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Failed-to-cancel-update-tools-task-and-stop-vmguest-max-tries/m-p/2292678#M80854</guid>
      <dc:creator>vin01</dc:creator>
      <dc:date>2020-07-23T11:15:52Z</dc:date>
    </item>
  </channel>
</rss>

