Skip to main content
Delphix

Running Hooks Under PowerShell Version 7 (KBA9892)

 

 

KBA

KBA# 9892

Applicable Delphix Versions

Click here to view the versions of the Delphix engine to which this article applies
Major Release All Sub Releases
7.0 and higher 7.0 and higher
6.0

6.0.3.0, 6.0.3.1, 6.0.4.0, 6.0.4.1, 6.0.4.2, 6.0.5.0, 6.0.6.0, 6.0.6.1, 6.0.7.0, 6.0.8.0, 6.0.8.1, 6.0.9.0, 6.0.10.0, 6.0.10.1, 6.0.11.0, 6.0.12.0, 6.0.12.1, 6.0.13.0, 6.0.13.1, 6.0.14.0, 6.0.15.0, 6.0.16.0, 6.0.17.0, 6.0.17.1, 6.0.17.2

How to Run Hooks Under PowerShell Version 7

Delphix 6.0.3.0 and higher allows the use of PowerShell versions from 2.0 to 5.1 (prior versions were restricted to PowerShell 2.0). Under the newer releases, Delphix allows the following selections when running PowerShell hooks:

  1. Run PowerShell Command (with default version)
  2. Run PowerShell Command (with version 2)

When selecting the first option, Delphix will use the default available PowerShell version on each host up to PowerShell 5.x.

With the release of PowerShell 7, PowerShell 5 and 7 run side by side and so the "default" is still 5 when you run the "powershell.exe" command as Delphix does when it runs the hooks. PowerShell 7 now uses "pwsh.exe". In summary:

  • PowerShell 5.1 uses Powershell.exe
  • PowerShell 7.3 uses pwsh.exe

Prerequisites

Windows host with PowerShell 7.x installed.

To run a hook under PowerShell 7.x

Complete the following procedure to run a hook under PowerShell 7.x

  1. Create the hook with the Operation Type set to "Run PowerShell Command (with default version)". This will not work with the "version 2" setting.
  2. Call the PowerShell 7 executable "pwsh.exe" in the hook's "Script" section to run the desired script under PowerShell 7:
  3. pwsh.exe C:\Users\delphix\Downloads\adduser.ps1; exit $LASTEXITCODE
  4. Test the hook script by provisioning, rewinding or refreshing the VDB.

Related Articles

The following articles may provide more information or related information to this article: