Adding a Snap in with Error Handling

Powershell

Adding a Snap in with Error Handling

This example uses the Xen App Commands snapin but can obviously be edited for any snapins

1
2
3
4
5
6
7
8
9
10
11
#add the Xen App Commands powershell Snapin
 
if (-not(Get-PSSnapin "Citrix.Xenapp.Commands" -ErrorAction Silentlycontinue)) {
	try {
		Write-Verbose "Adding the Xen App Commands PowerShell Module"
		Add-PSSnapin "Citrix.Xenapp.Commands" -ErrorAction Stop 
	}
	catch {
		Write-Error $error[0]
	}
}

Leave a Reply

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