Remark : as of the time I was writing this article the vCheck for Horizon sba hasn’t been published yet. Contact me if you want me to send you the xml file.
Last week I have been doing a few small updates to the vCheck for Horizon. The file with the encrypted password is now replaced by an xml file that holds all of the credentials and is usable directly for Horizon connections. I have been using this for my blog posts and demo’s for a while already. Also I have renamed the security & composer plugins by default to old as those have been deprecated and I don’t want to have them active by default anymore. Further I have done some small changes to other plugins.
Creating the xml file
this can be easily done like this:
$creds = get-credential $creds | export-clixml filename.xml
as you might have seen during my demo’s you can use this $creds object to make a connection.
$creds = import-clixml filename.xml $server = connect-hvserver connectionserver.fq.dn -credential $creds
Make sure to save this file to a good location and edit the “00 Connection Plugin for View.ps1” file with the proper location. I haven’t completely removed the old ways yet, they’re still partially there.
Running the vCheck script from ControlUp
Before everything else: make sure the machine that will run the vCheck has the latest version of PowerCLI installed. Download it here, and unpack the modules to “C:\Program Files\WindowsPowerShell\Modules” like this:
There are several things that I needed to do before I was able to run the vCheck from the ControlUp console or as an Automated Action (more on this later!). First I needed a way of providing credentials to the script. This is something I do using the Create Credentials for Horizon Scripts script action. If you already use some of the other Horizon related sba’s or the Horizon Sync script you might already have this configured. What it essentially does is creating an xml file as described above in a folder dedicated for ControlUp and usable by the service account that ran the sba. More on this can be found here.
Next was a way to get the vCheck itself. I do this by downloading it from github and unpack the zip file to C:\ProgramData\ControlUp\ScriptSupport\vCheck-HorizonView-master if downloads from the interwebz aren’t available you can download and unzip it yourself, just make sure it looks like this:
Next would be all the settings for email, connection server etcetera. This is all done trough the Script Action Arguments. WHat technically happens is that the Script Action removes both the globalvariables.ps1 and the “00 Connection Plugin for View.ps1” files and recreates them with those settings.
Once you have downloaded the vCheck you can run it manually so right click any random machine and select the vCheck for Horizon.
and fill in all the details you need. If you set the Send Email to false there is no need for the rest of the info.
Once you see this screen the script has completed, make sure to read the last line for the correct status and where you saved to file to.
And on my d:\ I see the file (and some others I used for testing)
And even better I received it in my mail as well
But but wasn’t the vCheck all about running it automagically?
Well yes it is and you can do that starting with version 8.5 that we have announced today! For now it will need to run hourly but in future releases we can also do this once a day. What you need to do for this is first change the default for the script action. Select that sba and hot the modify button.
Under settings you can keep the execution context as console (this will use the monitor when you run it as an automated action) or select other machine to pick a scripting server. Also make sure to select a shared credential that has a Horizon credentials file created on this machine.
Now go to the arguments tab and edit the default settings to set them to what you need.
Editing the first one
and done, press ok after this.
Now click finalize so the monitors can also use them and go trough all the steps ( no need to share with the community) an dmake sure the ControlUp Monitors have the permissions to run the sba.
Next we go to triggers > add trigger and select the new type: scheduled and click next
select the hourly schedule and a proper start and end time and click next
On the filter criteria make sure that you set the name to a single machine, otherwise the script will run for all machines in your environment. I recommend the same machine you used for the execution context. Keep in mind that the schedule functions just like any other trigger so you need to filter properly to what machine it applies and if you don’t it will apply to all of them.
You can select the folder this machine resides in and/or select a schedule to run the script in.
At the follow-up actions click add and select run an action from the pulldown menu. Under script name select the vCheck for Horizon, click ok and next
Make sure to create a clear name and click finish
The html should automatically end up in the export location and in your email.