Part 3: uipathcli - It's show time ??

Part 3: uipathcli - It's show time ??

Part 1: Part 1: uipathcli - Getting started!

Part 2: Part 2: uipathcli - Setup it on Windows OS

We've explored what UiPath CLI is and how to set it up—now it's time for the grand finale!

In this final part of the series, I'll walk you through a script to tackle the real-world problem I mentioned in Part 1. For those who need a refresher (and a bit of suspense), here it is again. Stay tuned! ???

Use Case:

The production support team wants to monitor and ensure the smooth operation of all scheduled automation bots for the day. They need to know which bots are going to run today and in their shift, so they can be prepared to handle any issues promptly.

Solution:

Here is the full script with code comments which explains every line of code.

# Define date format for today
$today = Get-Date -Format "yyyy-MM-dd"

# Query to get triggers from UiPath Orchestrator
$response = uipath orchestrator process-schedules get --folder-id 17132

# Convert the JSON response to a PowerShell object
$data = $response | ConvertFrom-Json

# Check if the response contains any schedules
if ($data.value) {
    # Filter schedules to find those with StartProcessNextOccurrence starting with today's date
    $result = $data.value | Where-Object { $_.StartProcessNextOccurrence -like "$today*" }
    
    # If any schedules are found, write them to a CSV file
    if ($result) {
        $result | Export-Csv -Path "C:\UiPath CLI\Scripts\ProcessSchedules_$today.csv" -NoTypeInformation
        "Data has been written to ProcessSchedules_$today.csv"
    } else {
        # Log a message if no schedules are found with today's date
        "No schedules found with today's date."
    }
} else {
    # Log a message if no data is returned from the API
    "No data returned from the API."
}
# Add a 5-second delay to see the output of the execution.
Start-Sleep -Seconds 5        

You can copy this full script, past it into a text file and save it with file extension .ps1. Your file will look like this now.

Now we are ready to run the code. Remember your output will be saved at the file path

"C:\UiPath CLI\Scripts\ProcessSchedules_$today.csv"        

This you can modify in script as per your requirement.

Now right click on the file and click on Run with PowerShell

If your command prompt gets closed instantly like below screen, it means the script execution is disabled.

Enable Script execution - Optional [One time]

Enter this command in PowerShell to enable scripting for the current user.

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser        

Now everything is set. Here are the today's 2 triggers on Orchestrator:

Output of the script:

There are endless possibilities and use cases where you can use uipathcli.


As we wrap up this series on uipathcli, we hope you've found these articles both enlightening and empowering. Here's a quick recap of what we've covered:

Part 1: uipathcli - Getting Started! We began with the basics, introducing you to the UiPath CLI, its purpose, and the benefits it brings to your automation toolkit.

Part 2: uipathcli - Setup on Windows OS Next, we guided you through the installation and configuration process on a Windows system, ensuring you're equipped with the tools needed to unlock the full potential of UiPath CLI.

Part 3: uipathcli - It's show time Finally, we dived into a practical example, showing you how to write and execute a script to retrieve scheduled triggers, demonstrating the power and simplicity of using uipathcli in real-world scenarios.

By now, you should feel confident in your ability to harness uipathcli to streamline your automation processes, boost productivity, and take full control of your workflows—all with the ease of a few simple commands.

Stay curious, keep experimenting, and continue to explore the endless possibilities that uipathcli has to offer. Until next time, happy automating!

Akash Javalekar

RPA Developer UiPath | AI Center | Document Understanding | UiPath-SAIAv1 Certified

3 周

It’s really interesting sometime due to network latency even developers lack to go to orchestrator and check but this is really helpful thanks Ashok for sharing ??

Amit Khyade

Sr. RPA Developer | UiPath Certified Professional Developer

3 周

Ashok, it's really helpful ?? The wait is over and we can start using this! I just wanted to confirm in case the client or support team does not have access to orchestrators, but they wanted to see sometime things over orch then they can also use this? Or we need orch access/license

要查看或添加评论,请登录

Ashok Karale的更多文章

社区洞察

其他会员也浏览了