How to Upload Packages to Orchestrator using Powershell Command

How to upload packages to Orchestrator using Powershell command?

Orchestrator API can be used to upload a package with Invoke Powershell , please follow below steps: 

  • Open PowerShell with administrator rights
  • Run the following commands one by one to install a Powershell library to interact with the Orchestrator

PS C:\>Install-PackageProvider -Name NuGet -Force

PS C:\>Register-PSRepository -Name UiPath -SourceLocation https://www.myget.org/F/uipath-dev/api/v2

PS C:\>Install-Module -Repository UiPath -Name UiPath.Powershell -Force

PS C:\>Install-PackageProvider -Name NuGet -Force

PS C:\>Register-PSRepository -Name UiPath -SourceLocation https://www.myget.org/F/uipath-dev/api/v2

PS C:\>Install-Module -Repository UiPath -Name UiPath.Powershell -Force

PS C:\>Import-Module UiPath.PowerShell

  • Authenticate the request. Please find below script to authenticate the request. Replace the Orchestrator URL, Username and Password 

   PS C:\>Get-UiPathAuthToken -URL <orchestratorurl> -Username <OrchestratorUser> -Password <password> -Session

 

NOTE - This Authentication session is valid for 30 minutes(i.e Once successfully authenticated, You can call any request for next 30 mins.)

  • Post this, package can be added by running the following command 

 Add-UiPathPackage "C:\PackageLocation" 

 

Attached a script that can upload all packages from a folder to Orchestrator

 

Import-Module UiPath.PowerShell

Get-UiPathAuthToken -URL <orchestratorurl> -Username <OrchestratorUser> -Password <password> -Session

$files = Get-ChildItem "C:\PathToPackagesFolder"

foreach ($file in $files){Add-UiPathPackage $file.FullName}