Powershell script within the JOBS fails: "Value cannot be null. Parameter name: s"
search cancel

Powershell script within the JOBS fails: "Value cannot be null. Parameter name: s"

book

Article ID: 272976

calendar_today

Updated On:

Products

CA Automic Workload Automation - Automation Engine

Issue/Introduction

The Powershell script executed within the JOBS is failing withe error message below.

====================================================================

Exception calling "SecureStringToBSTR" with "1" argument(s): "Value cannot be null.

Parameter name: s"

====================================================================

Environment

Component: CA Automic Workload Automation - Automation Engine

Release : 21.x

Cause

The powershell script is sexecuted with the parameters below.

pwshell.ps1 -vip <hostname/IP address> -username <username> -domain LOCAL -wait -progress -outputlog -abortIfRunning -jobName <jobname>

The pwshell.ps1 contains the script below, which prompts for password. This is where the error message is coming from since the parameters provided when running pwshell.ps1 does not contain any password.

====================================================================
    if(!$passwd){
        __writeLog "Prompting for Password"
        $secureString = Read-Host -Prompt "Enter your password" -AsSecureString
        $passwd = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR( $secureString ))
    }
    $opwd = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($passwd))
====================================================================

 

Resolution

The issue can be fixed by either putting the parameter -Password or -noPrompt as shown below.
 
pwshell.ps1 -vip <hostname/IP address> -username <username> -password <password> -domain LOCAL -wait -progress -outputlog -abortIfRunning -jobName <jobname>
 
 
or 
 
pwshell.ps1 -vip <hostname/IP address> -username <username> -noPrompt -domain LOCAL -wait -progress -outputlog -abortIfRunning -jobName <jobname>