PSM: Hardening script fails with Write-Log is not recognized and $StepUnitStatusTracker errors

PSM: Hardening script fails with Write-Log is not recognized and $StepUnitStatusTracker errors

155
Created On 11/10/26 11:00 AM - Last Modified 11/10/26 12:58 PM


Symptom


Running the PSM hardening script (PSMHardening.ps1) fails with one or more of the following errors:

The variable '$StepUnitStatusTracker' cannot be retrieved because it has not been set.

write-log : The term 'write-log' is not recognized as the name of a cmdlet, function, script file, or operable program.



Environment


14.6 Privilege Cloud Privilege Cloud PSM

Cause


The PSM hardening script loads required modules and functions at an early stage using using module and dot-sourcing.

If the PowerShell session is affected by:

  • User or system PowerShell profiles

  • StrictMode configuration

  • Custom PowerShell environment settings

the module initialization may fail before logging functions and internal variables are created. As a result, secondary errors such as missing Write-Log and $StepUnitStatusTracker are reported.

This issue may occur even when:

  • Execution Policy is set to Unrestricted

  • Required files exist in the correct directories

  • File system permissions are correct



Resolution


Run the PSM hardening script from a clean PowerShell session without loading any profiles.

Steps

  1. Open Windows PowerShell as Administrator.

  2. Execute the following command: powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "cd 'C:\Program Files (x86)\CyberArk\PSM\Hardening'; .\PSMHardening.ps1"

This launches a PowerShell session that bypasses profile loading and execution policy checks for the duration of the script, allowing all required modules and functions to load correctly.



Actions
  • Print
  • Copy Link

    https://knowledgebase.paloaltonetworks.com/KCSArticleDetail?id=kA1hj0000001BEOCA2&lang=en_US&refURL=http%3A%2F%2Fknowledgebase.paloaltonetworks.com%2FKCSArticleDetail