Run Powershell command changing values of variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2016 10:22 AM
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.
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?
- Labels:
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2016 01:01 AM
HI Rebecca,
Many thanks for your reply. Unfortunately, we are still on the Eureka version but plan to upgrade to Geneva soon.
Would you recommend waiting until we upgrade to implement these new workflows and build them in Geneva instead so that we don't have to go back and rebuild them all again at a later date.
I would be interested in having a look at Helsinki at some point. I will drop you an email during the week and we can see if we can arrange a time to suit.
Cheers,
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2016 10:18 AM
There will always be a cool new feature in a newer releases. I would only wait if there are critical features in the newer releases you need. The power of ServiceNow is the flexibility in being able to achieve almost anything. I think with each release we are just removing the friction to achieve outcomes. It would be hard to make a recommendation without knowing the use cases you are trying to adopt.
Fuji introduced a significant change with Activity Designer. Prior to Fuji you authored Activity Definitions if you wanted reusable activities. This required you to write a lot of code. Activity Designer lets you build reusable activities without all of that code overhead. But even if you aren't planning on using the activity in multiple workflows, it is a better way to author activities for troubleshooting because of the well defined inputs and outputs.
Here are a list of Orchestration core features per release that could help accelerate your work:
Fuji:
- Overhaul of the Workflow Canvas
- Architecture Shift towards Codeless Automation (Activity Designer, Databus)
- Support for Application Scoping and App Store (App Scoping is central to internal development as well)
- Activity Templates: SOAP, REST, Probe, Run Script, Java Script, SSH
Geneva:
- Lots of cleanup and UI performance
- Activity Packs: Managed File Transfer, InfoBlox DDI, F5 Load balancer, SCCM
- Activity Templates: JDBC, JMS (text), SFTP
- Investments in Codeless Automation: Auto-mapping for JDBC and SOAP
- UX Improvements: Web Services, Ability to test the Activity Inputs without having to author a workflow
- Web Services Security: REST OAuth, Mutual Auth
- Orchestration ROI - Ability to measure potential ROI, Calculate costs on tasks you have in the system that could be automated,
- Domain Separation for MID server credential selection
- Advanced Scripting - Ability to store any script file (Perl, Python, Ruby, .profile, etc.) in the MID Script Files and sync them to the server just in time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2016 11:59 AM
I generally set up workflow scratchpad variables in a previous activity and then use them directly in the Run Powershell like this:
$PSFolder = "${workflow.scratchpad.myVariable}"
Get-Acl -Path $PSFolder | Format-List
You can use current.variables like that as well if the path came from a cat item variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2016 12:40 PM
In order to future proof your activities, I would highly recommend that you avoid use of scratchpad variables inside your activity scripts. Use Activity Designer, define inputs, use the input in the execution.
Well defined inputs and outputs are the way to go. See my previous post above.
Let me know if you have questions or concerns.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2016 01:37 PM
Hi Rebecca,
Thank you for the recommendation. We are relatively new on Fuji, but have been using Runbook/Orchestration (and Run Powershell specifically) for over two years now. We started with Orchestration while on Berlin. Would you recommend that we go back to our old workflows and update them all to use the Activity Designer instead?