Remote Installing With Powershell linked to Citrix Scheduled Reboot

We had to find a way to install package (hotfix or msi ) on our servers juste before the Citrix scheduled reboot, as we try to limit the effects on our users. We also want the script to be the most multi-purpose, then we decided to put all applicable actions in an xml file (action_list.xml) with the following syntax :

<actions>
	<action name="action1">
		<file>\\server\share\file1.msi</file> 
		<script>c:\windows\system32\msiexec.exe /i c:\tmp\file1.msi /l*v c:\tmp\file1.log /quiet /norestart</script>
		<clean>file1.log</clean>
		<clean>=== Verbose logging stopped:</clean>
	</action>
(...)
	<action name="actionx">
		<file>\\server\share\filex.exe</file> 
		<script>c:\tmp\filex.exe log:c:\tmp\filex.log /norestart</script>
		<clean>filex.log</clean>
		<clean>KBXXXXXXXX</clean>
	</action>
</actions>

In a CSV file, we store Citrix folders and the required actions

Folder;Action
Servers/MyInfra;action1
Servers/MyApp1;actionX

Finally, we prefered to make the choice of a dynamically declared variables to store actions rather than insert them into an hashtable, the script is more brief and lisible.
A variable is initialized with the cmdlet New-Variable

PS>New-Variable -Name Toto -Value titi
PS>$toto
titi

We can access to its content with the cmdlet get-variable

PS > get-variable -Name toto

Name                           Value
----                           -----
toto                           titi


PS > get-variable -Name toto -valueonly
titi

Here come the full script

Leave a Reply

Your email address will not be published. Required fields are marked *