{"id":891,"date":"2019-11-20T11:48:19","date_gmt":"2019-11-20T11:48:19","guid":{"rendered":"http:\/\/172.23.1.43\/?p=891"},"modified":"2022-06-07T22:25:58","modified_gmt":"2022-06-07T22:25:58","slug":"workspace-one-uem-powershell-profile","status":"publish","type":"post","link":"https:\/\/blog.n-dol.org\/2019\/11\/20\/workspace-one-uem-powershell-profile\/","title":{"rendered":"Workspace ONE UEM – PowerShell Profile"},"content":{"rendered":"\n

We can do a lot of things in Workspace ONE UEM especially when it comes to custom profile. We can do custom profile for OMA-DM client but we can do it Intelligent Hub too. An interesting profile for the Intelligent Hub is the PowerShell one, little known but very useful. This profile allow to run PowerShell commands from Intelligent Hub.<\/p>\n\n\n\n

Sensors Vs Profile<\/h2>\n\n\n\n

You could argue that with Sensor within the console you can do the same. While this is true, you have to remember that Sensor is for taking the “pulse” of the device and returning information back so it can bring more data so more insight.
The profile on the other hand is there to do configuration of the device.<\/p>\n\n\n\n

32 Bits Vs 64 Bits<\/h2>\n\n\n\n

Intelligent Hub currently run as a 32 bit process. So any command run from there would access to the 32 bit side, like registry and System32 folder.<\/p>\n\n\n\n

To run something in 64 Bits, you need to use sysnative<\/code> which will target the right folder or registry access.<\/p>\n\n\n\n

Sending PowerShell commands<\/h2>\n\n\n\n

To send PowerShell commands, you need to use the following profile. <\/p>\n\n\n\n

<wap-provisioningdoc id="INSERT-GUID" name="customprofile">\n  <characteristic type="com.airwatch.winrt.powershellcommand" uuid="INSERT-GUID">\n    <parm name="PowershellCommand" value=""\/>\n  <\/characteristic>\n<\/wap-provisioningdoc><\/code><\/pre>\n\n\n\n

Insert the command in the value<\/code> string and insert new GUID for id<\/code> and uuid<\/code>.<\/p>\n\n\n\n

You can use the following command to generate new GUID<\/p>\n\n\n\n

[GUID]::NewGuid().ToString()<\/code><\/pre>\n\n\n\n

Example:<\/p>\n\n\n\n

<wap-provisioningdoc id="b0774572-29ec-4015-8bde-8f0281682f1b" name="customprofile">\n  <characteristic type="com.airwatch.winrt.powershellcommand" uuid="f060bc02-bc0d-4ff8-b5d7-3fdfd24274dd">\n    <parm name="PowershellCommand" value="Invoke-Command -ScriptBlock {C:\\windows\\ccmsetup\\ccmsetup.exe \/uninstall}"\/>\n  <\/characteristic>\n<\/wap-provisioningdoc><\/code><\/pre>\n\n\n\n

As you can see we can do anything PowerShell related, but how about scripts.<\/p>\n\n\n\n

Sending PowerShell script<\/h2>\n\n\n\n

You can inject script in the value but it can be tricky due to XML parsing so there is escape to be done and it can result in not having the script to run properly. PowerShell offer another way to execute a script without a .ps1<\/code> file, which is -EncodedCommand<\/code> switch. It uses Base64 encoding to avoid issue with special characters.<\/p>\n\n\n\n

To encode a PowerShell command to Base64 you need to do the following:<\/p>\n\n\n\n