IT Process Automation

 View Only
  • 1.  Passing Parameters into Powershell Script

    Posted Feb 04, 2016 10:44 AM

    I'm trying to pass a 'Process.' variable into PowerShell script using the parameters built into the Run Script operator but without an success.

    Below is what I currently have in the Inline Script box:



    Get-ChildItem -Path \\%%%source path%%% -Recurse | Where-Object {$_.Name -Like "*$var1"} | Move-Item -Destination \\%%%destination path%%%


    Is there a less verbose way to pass that variable into the Where-Object?


    I was reading the documentation here and liked the concept at the bottom of just using '%1' but haven't had any luck getting that to work.


    I also found a post in the community but it didn't have an code samples

    ITPAM and PowerShell


    Any thougts or suggestions on how to streamline passing in variables?


  • 2.  Re: Passing Parameters into Powershell Script
    Best Answer

    Posted Feb 05, 2016 05:52 AM
      |   view attached

    I put in embedded PS inside like this:

    [string] $var1
    Get-ChildItem -Path C:\Temp -Recurse |Where-Object {$_.Name -like "*" + $var1 + "*"}



    to pass the variable, put in parameters in component like this sample attached. remember to mark thex check 'rear output for data set variable'


    zip   5 KB 1 version

  • 3.  Re: Passing Parameters into Powershell Script

    Posted May 30, 2017 11:18 AM

    This seems to work but i cant seem to get multiple parameters to work... 


    For Instance:

    [string] $var1, $var2
    Get-Service -ComputerName "$var1" -Displayname "$var2" | Format-Table -Property status, displayname -AutoSize

  • 4.  Re: Passing Parameters into Powershell Script

    Posted May 30, 2017 03:07 PM

    Nevermind... figured it out. The issue really was the spaces being removed in the script. 

    I needed to wrap the parameters in the script operator parameter Properties panel. Like so...


    ("'") or double quote single quote double quote



    Then the actual script i was running: 



    Multiple params work and the spaces issue is resolved.