<?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>BTA25 Tracker</title>
    <link>https://communities.vmware.com/wbsdv95928/tracker</link>
    <description>BTA25 Tracker</description>
    <pubDate>Fri, 24 Nov 2023 06:40:18 GMT</pubDate>
    <dc:date>2023-11-24T06:40:18Z</dc:date>
    <item>
      <title>Horizon 8 (non REST) Script for scheduled refresh doesn't work</title>
      <link>https://communities.vmware.com/t5/Horizon-Desktops-and-Apps/Horizon-8-non-REST-Script-for-scheduled-refresh-doesn-t-work/m-p/2870038#M94978</link>
      <description>&lt;P&gt;Horizon 8 (non REST) Script for scheduled refresh doesn't work&lt;BR /&gt;Hi,&lt;/P&gt;&lt;P&gt;We've recently upgraded to VMware Horizon 8 and we want to have a nightly refresh for all our VDI VMs. After searching online, I've created the following script.&lt;/P&gt;&lt;P&gt;However, when I run the script, there's nothing happening within vCenter or View admin dasboard with the VMs I like to refresh.&lt;/P&gt;&lt;P&gt;I'm using the following script:&lt;/P&gt;&lt;P&gt;$KeyFilePath = 'C:\Scripts\VDIscript\key_.key'&lt;BR /&gt;$CredPath = 'C:\Scripts\VDIscript\Cred.xml'&lt;/P&gt;&lt;P&gt;$ErrorActionPreference = 'SilentlyContinue'&lt;BR /&gt;Start-Transcript -Path 'C:\Scripts\VDIscript\Refresh-DesktopsByAPI.log' -Force&lt;/P&gt;&lt;P&gt;#decrypt credentials&lt;BR /&gt;$Key = Get-Content $KeyFilePath&lt;BR /&gt;$credXML = Import-Clixml $CredPath # Import encrypted credential file into XML format&lt;BR /&gt;$secureStringPWD = ConvertTo-SecureString -String $credXML.Password -Key $key&lt;BR /&gt;$Credential = New-Object System.Management.Automation.PsCredential($credXML.UserName, $secureStringPWD) # Create PScredential Object&lt;/P&gt;&lt;P&gt;Write-Host "Loading VMware modules" -ForegroundColor Green&lt;BR /&gt;Import-Module -Name VMware.VimAutomation.HorizonView&lt;/P&gt;&lt;P&gt;#Connect to the Horizon View connection server&lt;BR /&gt;$hvServer = Connect-HVServer -Server 'FQDN servername' -User saView8scheduledtask -Password 'INSERTPASSWORD' -Domain DOMAIN.local&lt;BR /&gt;$services = $hvServer.ExtensionData&lt;/P&gt;&lt;P&gt;$spechelper=New-Object VMware.Hv.DesktopService+DesktopRefreshSpecHelper&lt;BR /&gt;$specbase=New-Object VMware.Hv.DesktopRefreshSpec&lt;/P&gt;&lt;P&gt;$Machines = (get-hvmachine | where { $_.base.DesktopName -eq "FL-W10-Basic-POC" })&lt;BR /&gt;#[Vmware.Hv.machineid]$machineIDs=(Get-HVMachine -PoolName "FL-W10-Basic-POC").id&lt;BR /&gt;$machineIDs=(Get-HVMachine -PoolName "FL-W10-Basic-POC").id&lt;BR /&gt;# DesktopID is PoolID&lt;BR /&gt;$PoolID = (Get-HVPool -PoolName "FL-W10-Basic-POC").id&lt;/P&gt;&lt;P&gt;$Machines.base.desktop | foreach {&lt;BR /&gt;$desktoprefreshSpec.StartTime = $null&lt;BR /&gt;[Vmware.Hv.DesktopID]$deskid=$PoolID&lt;BR /&gt;$spec=$specbase&lt;BR /&gt;$spec.logoffsetting=$spechelper.LOGOFF_SETTING_FORCE_LOGOFF&lt;BR /&gt;$spec.machines=$machineIDs&lt;BR /&gt;$services.desktop.desktop_refresh($deskid, $spec)&lt;BR /&gt;}&lt;BR /&gt;disconnect-HVServer -Server $hvServices -Confirm:$false&lt;/P&gt;&lt;P&gt;Stop-Transcript&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I put a breakpoint in the script and halt it before running the line:&lt;/P&gt;&lt;P&gt;$services.desktop.desktop_refresh($deskid, $spec)&lt;/P&gt;&lt;P&gt;I see the following data within the key variables: (see attached screenshot)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="2021-10-04 15_28_36-.png" style="width: 999px;"&gt;&lt;img src="https://communities.vmware.com/t5/image/serverpage/image-id/91346i42F42EFE65AB9AFF/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="2021-10-04 15_28_36-.png" alt="2021-10-04 15_28_36-.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Could somebody tell me what I'm missing here?&lt;/P&gt;</description>
      <pubDate>Mon, 04 Oct 2021 13:32:07 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/Horizon-Desktops-and-Apps/Horizon-8-non-REST-Script-for-scheduled-refresh-doesn-t-work/m-p/2870038#M94978</guid>
      <dc:creator>BTA25</dc:creator>
      <dc:date>2021-10-04T13:32:07Z</dc:date>
    </item>
  </channel>
</rss>

