On January 19th 2020 the first public version of the Citrix WEM Powershell Module (Citrix.WEMSDK) was published to the Powershell Gallery (https://www.powershellgallery.com/packages/Citrix.WEMSDK).
The Powershell Gallery page will also show installation instructions, be it using the Install-Module method, or a manual download.
As this is the first release of a whopping 243 commands, the documentation on a per function level is severely lacking at the moment. Don’t worry, it is on my to-do list.
This post is to introduce a powershell script (Citrix.WEMSDK.functiontests.ps1) which can be used to lookup all the functions and see what is needed to effectively use the function.
So you need several things.
First you need to install (and import) the module.
Then you need to download the Citrix.WEMSDK.functiontests.ps1 script from https://raw.githubusercontent.com/msfreaks/Citrix.WEMSDK.scripts/master/Citrix.WEMSDK.functiontests.ps1
And of course you need access to a database server with the WEM database. I recommend using this in a test or lab environment first, until you are comfortable enough to use it in a production environment.
Recommended extra requirements: the Active Directory and Applocker powershell modules. The first can be acquired by installing the Active Directory RSAT tools (more info on that: https://support.microsoft.com/en-us/help/2693643/remote-server-administration-tools-rsat-for-windows-operating-systems), the second comes natively with Windows 10 and at least Windows Server 2016. The first helps a lot when working with the ADObject functions, the second is a requirement for working with the AppLockerRule functions.
Before using the script to test the functions, you need to modify some stuff in the script to match your environment.
Modify the database settings to match your environment.
These settings are used throughout the function tests. It is not required that these are actual shares. They are just here to test the functions, no actual resolving is done, nor will the shares actually be accessed by the functions.
These settings are also used throughout the function tests. If you do not have the Active Directory module, you will need to enter SID values for each variable (e.g. $SID1 = “S-1-5-21-1644858761-3736240991-3467507639-1299”). If you do use the Active Directory module, as shown in the screenshot, you need to have connectivity to the Active Directory as well.
Those modifications are a onetime deal for this script. You are now good to go test the functions.
All functions are bundled in Powershell Regions. For example, the screenshot below shows all related functions for working with the Configurations (or Sites).
The script ends with a section that outputs arrays of objects that might have been created during the script.
So the recommended way of using this script would be to:
- Load the script in your favorite Powershell IDE (like Powershell ISE or Visual Studio Code)
- Select everything from line 1 to line 35
- Execute the selection (F8)
Which loads the module and your variables, and sets up the database connection
- Find the function or functions your wish to test or find out how to use them, and select those lines
- Execute the selection (F8)
- Examine the results
That said, if you have all prerequisites in place, and you have correctly edited the variables, nothing is stopping you from running the entire script. You should end up with a fully configured Configuration that you can examine using the WEM Administration Console.
https://msfreaks.wordpress.com/2020/02/17/citrix-wemsdk-powershell-module-for-citrix-wem/ is the official announcement for the Citrix.WEMSDK Powershell Module.