PowerShellComponent ExecuteScript - Missing argument in parameter list

Hi everybody,

I am facing a problem using the PowershellComponentNet4 - ExecuteScript process task. I have the following script as parameter:

Dim samAccountName As String = $SAMAccountName$
Dim username As String = Connection.GetConfigParm("Custom\TargetSystem\QuotaDB\Username")
Dim password As String = Connection.GetConfigParm("Custom\TargetSystem\QuotaDB\Password")

Dim script As New StringBuilder()

script.AppendLine(String.Format("$$ArgumentList = " + samAccountName + " -Q 500mb"))
script.AppendLine(String.Format("$$securePassword = ConvertTo-SecureString " + password + " -AsPlainText -Force"))
script.AppendLine(String.Format("$$credential = New-Object System.Management.Automation.PSCredential (" + username + ", $$securePassword)"))
script.AppendLine(String.Format("Start-Process -FilePath M:\Test\Test.exe -ArgumentList $$ArgumentList -Credential $$credential -RedirectStandardOutput M:\PowerShell_Skripte\Output.txt -RedirectStandardError M:\PowerShell_Skripte\Err.txt"))

value = script.ToString()

The script basically runs an executable and passes on three parameters needed. If I run the script in PowerShell it works just fine. Compiling (Designer) and simulation (ObjectBrowser) are also fine too. Upon starting the process with this script, I get the following error message:

ErrorMessages (2021-03-15 09:52:11.800) [System.Management.Automation.ParseException] At line:3 char:90
+ ... em.Management.Automation.PSCredential (xxx\userxxx, $secure ...
+                                                                 ~
Missing argument in parameter list.
   at StdioProcessor.StdioProcessor._Execute(Job job)
   at VI.Jobservice.JobComponents.PowershellComponentNet4.Activate(String task)
   at VI.Jobservice.JobComponents.PoshBaseTask.Execute()
   at VI.Base.PowerShell.Runner.RunspaceUtils.Run(Runspace target, IPoshExecutionItem item, Int32 maxDeserDepth)
   at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)

Can somebody tell me what I doing wrong here? Thanks in advance!

  • I tried to create a Powershell script with the string builder but it got way too difficult to read so I created a Powershell-file and got the contents of the file into a string builder, and in the file I called a secure string from a file.

    That's how I solved it.

    PS. Does the account running the job server have access to M: or even have it mapped?