Invoke PowerShell script with assemblies

Hi,

I’ve made script that creates zips like this:
ZIPPowershell.xaml (6.8 KB)

I’ve put arguments inside of invoke file that matches variables. Whole script is " " and is readable as string also i need to use names from excel sheet and assign them to PS variables

How can I make it work?

@Alko

your missing a value , Assign value to arg_zapisZIP .
it should work.
Be careful when using direction in PowershellVariable in property section.

Hello @Alko,

to transfer variables you can use the following approach. Use a multi command PS, separate the single commands with a semicolon:

"Param([string]$var1);Add-Type -AssemblyName System.Windows.Forms;[System.Windows.Forms.MessageBox]::Show($var1)"

As you can see I concatenate here three PS commands. The first is a Param, the second the Add-Type and the last calls a method of this library and uses the content of the variable.

All you have to do now is to define an parameter with in direction.

uipath_ps003

uipath_ps004

Best regards
Stefan

Hi @StefanSchnell,

thanks for your solution. Unfortunetly when I run It I’ve recieved following error:

{
“message”:

"System.Management.Automation.CommandNotFoundException: The term ‘Param([string]$arg_zapis,[string]$arg_zapisZIP);Add-Type -Assembly system.io.compression.filesystem;[io.compression.zipfile]::CreateFromDirectory($arg_zapis,$arg_zapisZIP)’

is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.\r\n at System.Activities.Statements.Throw.Execute(CodeActivityContext context)\r\n at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)\r\n at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)\r\n at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)",
}

Here is a code:

“Param([string]$arg_zapis,[string]$arg_zapisZIP);Add-Type -Assembly system.io.compression.filesystem;[io.compression.zipfile]::CreateFromDirectory($arg_zapis,$arg_zapisZIP)”

I would really appreciate Your help.

Regards,
Aleksander

1 Like

@Alko

Hello Aleksander,

your script works perfect in my environment. As attachment the XAML file.

Let us know your results.

Best regards
Stefan

Sequence.xaml (5.4 KB)

@Alko- Try run with Admin mode.