4

I am kicking off a PowerShell script with UiPath. I need to pass an argument in, from UiPath. Firstly is this possible and secondly does anyone have an example of this? Not sure what the syntax is for this in the PowerShell script

Ilya Kochetov
  • 17,988
  • 6
  • 44
  • 60
Dan Atkins
  • 378
  • 1
  • 7
  • 21

1 Answers1

4

Is it possible to pass arguments from UiPath to the terminal.

  • Your PowerShell script needs to be saved in a txt file.(PSSampleParameters.txt)

Code sample(PSSampleParameters.txt):

Param(
  [string]$computerName
)

[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") 
[System.Windows.Forms.MessageBox]::Show($computerName) 
  • Add a "Read Text file" activity and on filename add your PowerShell script.

Read Text File activity

  • Add "Invoke Power Shell" activity and be sure that you set "ContinueOnError" to True and check "IsScript"

Invoke Power Shell Activity

  • With "Invoke power shell" activity selected go to on right panel and click on "..." button from Parameters. In the screen that will open you can add your parameters.

Add Parameter

Andrei
  • 302
  • 4
  • 13
  • Well.. I have a process that connects to a shared mailbox by kicking off a powershell script.. I don't want to hardcore the username/password into the powershell pass it in via the uipath activity – Dan Atkins Mar 17 '16 at 16:06
  • can you check these 2 links: http://www.uipath.com/examples/it-automation-powershell-read-text-files & http://www.uipath.com/examples/it-automation-powershell-get-public-ftp-file ? – Andrei Mar 17 '16 at 16:22
  • There are more details here: [more examples](http://www.uipath.com/resources#stq=powershell&filters=solutions%20videoTutorials%20userGuides%20examples%20quickAnswers) – Andrei Mar 17 '16 at 16:23
  • Keep the user/password in the Windows credential store and send them as parameters to the PS: http://www.uipath.com/kb-articles/how-to-work-with-windows-credentials – mbadit Apr 26 '16 at 11:05