Run Powershell command changing values of variable

jfinn
Kilo Expert

I am testing a few powershell commands and one of these needs to pass through a file path so that we can check the permissions on it.   Currently I have a variable in which I enter my file path but when this gets passed through to the "Run Powershell" activity, the variable loses parts of the drive path.

Here is my code as it stands in the Run Powershell activity.   For testing purposes, on this occasion, I am passing the variable directly.

Powershell Issue.JPG

However, when I run the workflow and check, it fails with the following message:

Get-Acl : Cannot find path 'c:Userstestuser' because it does not exist.At C:\Users\SERVIC~1\AppData\Local\Temp\script.6618372681266526755.PS1:1 char:8+ Get-Acl <<<<   $Folder_Path | Format-List+ CategoryInfo                   : ObjectNotFound: (:) [Get-Acl], Ite

Note how it removes the \ after c: and also between users and testuser in the path.

Am I doing something wrong here or is is not possible to pass a path through as a variable?

11 REPLIES 11

Hi Robert,



For things you have authored that are working for you I wouldn't bother. I just want to make sure folks move to the new approach for net new things. Activity Designer was v1 in Fuji and we worked out some of the quarks in Geneva. Helsinki is going to have some pretty cool new functionality. I would be happy to share the plan with folks on the community under NDA and get your feedback.



If you are interested, feel free to ping me offline and we can setup a WebEx. rebecca dot dias at servicenow.



tx


becky


Hi Robert,



This worked for me.   I had previously been declaring my variable in the "PowerShell script variables" section using the code below:



{"PSFolder": "${workflow.scratchpad.FolderPath}"}



Once I changed this to declare them in the command instead as you suggested, it started passing through the complete file path and not removing any of the characters.



This is now working perfectly for me.



Many thanks


James