How to use powershell from an RPM filter

Problem: I'm trying to use RPM to launch a Windows Powershell script, but nothing inside the script seems to be running.

Solution: By default, the script execution policy in Windows Powershell is set to Restricted.  This prevents Powershell from running any scripts.  In order to allow scripts, you can use the Set-ExecutionPolicy cmdlet.  For instance, if you want to allow all scripts to run, you might run the following command from a Powershell command line:

Set-ExecutionPolicy RemoteSigned

You can also use the cmdlet to set the policy for a specific user using a command like this:

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned

Note: If you are using a 32-bit RPM on a 64-bit version of Windows, RPM will launch the 32-bit version of Powershell.  You should set the execution policy for both 32-bit and 64-bit versions of Powershell.  To set it for the 32-bit version of Powershell, you need to be running that version, so run C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe.  You can also edit the ExecutionPolicy entry in the following Registry keys:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell