VMware Horizon Community
kongfupanda
Contributor
Contributor

Scheduled task to run vmware view PowerCLI scrip to refresh virtual desktops-not working well

Hi Team, I have view 5.3 and need to use windows scheduled task to run a  script to to refresh the VM, but it shows running while no actual response on VC. If I  run the powerCLI and manually run two line of command to refresh the pool ID ,it works and the Vcenter shows the tasks running. Any advice what's wrong? Does it support ps1 fle? I saved these two lines in  ps1 file. please advise or give some examples,thanks!

0 Kudos
3 Replies
mpryor
Commander
Commander

When you click on the powerCLI shortcut in the start menu, it's running a ps1 script to load our cmdlets - have you incorporated that into yours?

0 Kudos
kongfupanda
Contributor
Contributor

no... any idea how to incorporate it?

do you refere to this ?

C:\Windows\system32\windowspowershell\v1.0\powershell.exe -noe -c ". \"F:\Program Files\VMware\VMware View\Server\extras\PowerShell\add-snapin.ps1\""

here below is my lines for the scripts:


$a = get-date ((get-date).AddMinutes(2)) -format "yyyy-MM-%d HH:mm"

Get-Pool -pool_id UAT | Get-DesktopVM | Send-LinkedCloneRefresh -schedule $a

0 Kudos
mpryor
Commander
Commander

Yes that one, the simplest solution is to call it directly:

.  F:\Program Files\VMware\VMware View\Server\extras\PowerShell\add-snapin.ps1

$a = ...

But you can also look at it's contents to see how it is loading our extension and mimic it.

0 Kudos