Running Powershell hook scripts from a network share (KBA5454)
KBA
KBA# 5454
Issue
Hook scripts are running with an Execution policy RemoteSigned, therefore it is not possible to run unsigned scripts from a network share (UNC) or the internet.
Prerequisites
A PS1 script should be shared and accessible by the target environment
Applicable Delphix Versions
- Click here to view the versions of the Delphix engine to which this article applies
-
Major Release All Sub Releases 6.0 6.0.0.0 5.3
5.3.0.0, 5.3.0.1, 5.3.0.2, 5.3.0.3, 5.3.1.0, 5.3.1.1, 5.3.1.2, 5.3.2.0, 5.3.3.0, 5.3.3.1, 5.3.4.0, 5.3.5.0 5.3.6.0, 5.3.7.0, 5.3.7.1, 5.3.8.0 5.2
5.2.2.0, 5.2.2.1, 5.2.3.0, 5.2.4.0, 5.2.5.0, 5.2.5.1, 5.2.6.0, 5.2.6.1
5.1
5.1.0.0, 5.1.1.0, 5.1.2.0, 5.1.3.0, 5.1.4.0, 5.1.5.0, 5.1.5.1, 5.1.6.0, 5.1.7.0, 5.1.8.0, 5.1.8.1, 5.1.9.0, 5.1.10.0
5.0
5.0.1.0, 5.0.1.1, 5.0.2.0, 5.0.2.1, 5.0.2.2, 5.0.2.3, 5.0.3.0, 5.0.3.1, 5.0.4.0, 5.0.4.1 ,5.0.5.0, 5.0.5.1, 5.0.5.2, 5.0.5.3, 5.0.5.4
4.3
4.3.1.0, 4.3.2.0, 4.3.2.1, 4.3.3.0, 4.3.4.0, 4.3.4.1, 4.3.5.0
Resolution
Providing the follow command at the start of the hook script will change and force the current Powershell process policy to Bypass, without affecting the global policy of target environment:
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force
For example:
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force
\\server\script\my_script.ps1
Troubleshooting
Execution and output of the Powershell script can be tracked in the Delphix debug connector logs, search for UserHook.ps1.
Related Articles
The following article may provide more information or related information to this article:
- https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy?view=powershell-5.1 - Microsoft's execution policy documentation and policy descriptions