Problem
ProfileUnity can leverage either Application Launcher or User Defined Scripts rules to run single-line commands. In instances where a more comprehensive script is required, these same rules can be modified to initiate said script if it's remotely accessible on the network. However, not all environments have remote access to network shares from which to call staged scripts and the contents of the script might be to complex to be performed within a single command.
Resolution
In the scenario above, it's sometimes possible to encode the entire contents of the script into a Base64 string and execute via Powershell as a single command. To do so, perform the following:
- Paste the following into a Powershell prompt to obtain the corresponding Base64 string:
[Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes(@'
Paste script content here...
'@))
- Create an Application Launcher rule like the example below, configuring other settings (timing, elevation, etc.) to suit your use case:
Filespec: C:\Windows\system32\WindowsPowerShell\v1.0\PowerShell.exe
Arguments: -executionpolicy bypass -windowstyle hidden -nologo -noprofile -encodedcommand "InsertBase64ValueHere"
Reference: PowerTip: Encode String and Execute with PowerShell
Product: ProfileUnity-FlexApp
Product Version: 6.8 and later