User input into a script in Powershell GUI - powershell

hoping for some help. I've got a dialog box that I want to do a certain action and running into issues getting the user input as a variable in the script. Essentially I want the user to be able to copy down a row in excel (so, for example, copy 4 numbers down a line in row E). I want the user to be able to paste it into the powershell GUI I made, once pasted I want the button to use that user input and put it in to a script I have already made and execute using each of those numbers as a variable and to return the output of the script. I've got the script and button made i'm just not sure what cmdlet or functions I need to do in order to take the user input and place in the script as a variable. Any help is appreciated, thank you!!
I went through Microsoft Docs and tried to find a cmdlet but either I didn't understand it or it didn't seem to work.

Related

Using an index of an array to build a user selection menu

I'm working on a PowerShell script which sets a variable based on a user selection from an array, but I can't find any approach to realize this.
There is a variable named $org which is filled by a cmdlet with an array of entries looking like this:
My goal is to create a user selection menu which prompts to select one entry of that array writing this selection to a variable which can be used in the ongoing script. The number of entries in that array can vary.
I tried something with switch-operator but no success. I'm completely stumped. :-/
Thank you,
Chris

Pentaho script invocation not working properly

I'm running a PowerShell script from pentaho, but I encounter the following problem. When it is called, the script step gets as parameter the rows that are processed by the previous step. From the images should be more clear what is the problem.
This is the complete transformation.
This is how the steps are configured.
Here are the parameters of the transformation before the script step.
This is the result after the execution. The string after the ....shell.bat contains the names of the rows that were processed by the previous step. If I do no process any row this string is not present. The problem is that this string should not be passed as parameter to the powershell.exe command, the first parameter should be the path to the script file. In fact in the row below (the output) the command is correct.
The problem is that I looked all the options and controlled all the variables, and seem everything ok. I'm not able to run the command successfully because I cannot remove this passed parameter (which I don't pass, but pentaho pass it by itself).
It is possible that is a bug or something? Can anyone give me some indications on how to solve this. Thank you.

How to pass parameters to a Powershell script with UiPath

I am trying to run a powershell script with uipath. I have found two approaches to run it;
Read the script as a text and pass to Invoke Powershell activity
Use Run powershell script activity from Script Activities package
Now I need to pass arguments to the powershell script from uipath. Some have mentioned about formatting the string with parameters and invoking the script.
But, rather than that, think we can directly pass parameters from UiPath.
In Run Powershell script, it has Parameters as input
In Invoke Powershell, it has Parameters under Input section and PowershellVariables under Misc
I have been searching for a while. But still I am unable to figure out how to pass parameters using above activities.
I am trying to send outlook mails using powershell. Still in the process of learning how to work with it. Plz help…
EDIT
Found solution for one approach. Added it as an answer.
Found an answer from this link. Out of the two approaches, it provides a solution to pass the parameters using Invoke Power Shell activity.
Read the .ps1/.txt file containing the script, with Read Text File activity
Call the Invoke Power Shell activity by passing file content as CommandText and parameters in the Parameter collection.
But, it would be great, if I can get to know how to pass parameters using Run power shell script activity.

Pulling data from and writing back to an Excel spreadsheet in PowerShell

Right, I'm putting a script together to be run post-Windows install to change a few settings, re-name the computer and join a domain. I've got everything working fine but where it currently asks the user to provide a computername (which they will be taking from a spreadsheet) I'd ideally like the script to take the next available name from the file and then write back a value for the adjacent field with a value provided by the user (the end-user's name).
Is this at all possible or am I expecting too much here?
Thanks in advance!
Check out the PowerShell Module https://www.powershellgallery.com/packages/ImportExcel/5.1.1

How to generate new numbers if i run the program everytime from the begining?

I am working on CATScript in optimization of a part.
When I run the script everytime it shoud provide numbers in ascending order.
For example if I run the program for the first time it should provide the output as " 1 "
and if I run the program again it shoud provide the output as " 2 " and so on.
I am stuck with this and I could not figure out th logic that we have to use here.
Looking forward for your help.
Thank you!!
An option (matlab based) could be to save a counter variable to a .mat-file at the end of the script, which is then loaded again at the beginning of the script.
That would allow you to keep track of how many times the script have been run.
In CATIA if it is being run multiple times on the same part/product, you could add a hidden, integer parameter to the specification tree and increment it each time the macro is run.
Another, more generic way would be to create a text file on the user's local and update the number in the text file.