Share a sample workflow that uses PowerShell script to find the top “N” processes using PowerShell that consumes the maximum memory and also share a sample implementation of using Powershell scripts with UiPath Studio.
ps | sort -p ws | select -last $ProcessCount | Out-File "Full Path of Output file"
P.S: Use this code in Notepad and save the same with anyName.ps1. Ensure to update "Full Path of Output file" parameter with the File path of the anyName.ps1.
Steps to Implement:
Note: Assuming the User will provide the number of processes ('N') as Input.
- Open UiPath Studio and create a sample process.
- Search for Input Dialog activity in Activities pane.
- Drag “Input Dialog” activity from the Activities pane into the designer pane to get the Input from the Human User and save the same to a variable.
- Search and Drag “Invoke Power Shell" activity into the designer panel.
- Enter the required parameters as shown below along with the input arguments.
- CommandText: Provide the Full file path of the saved script.
- Type Argument: System.Management.Automation.PSObject
- Input parameter: Variable stored as an output for Input dialog activity.
- Execute the automation script (When prompted, provide the desired value of Input dialog).
- Open the output file to see the below outcome: