UiPathOrch.psm1
|
# # Module script for module 'UiPathOrch' # # Generated by: Yoshifumi Tsuda # # Generated on: 2023/08/28 # #Set-Alias -Name job -Value Get-OrchJob #Set-Alias -Name log -Value Get-OrchLog #Set-Alias -Name stop -Value Stop-OrchJob Set-Alias -Name !Show-OrchGuide -Value Get-OrchHelp . $PSScriptRoot\Functions\Enable-OrchUserAttended.ps1 . $PSScriptRoot\Functions\Disable-OrchUserAttended.ps1 . $PSScriptRoot\Functions\Enable-OrchPersonalWorkspace.ps1 . $PSScriptRoot\Functions\Disable-OrchPersonalWorkspace.ps1 . $PSScriptRoot\Functions\Find-OrchFolderNoUserAssigned.ps1 . $PSScriptRoot\Functions\Get-OrchJobVideo.ps1 . $PSScriptRoot\Functions\Format-OrchQueueItem.ps1 . $PSScriptRoot\Functions\Format-OrchTestDataQueueItem.ps1 # Extend QueueItem with an Expanded property that flattens SpecificContent keys into a PSCustomObject. # (SpecificContent is the Dictionary form; SpecificData is the same content serialized as JSON string.) # Use: Get-OrchQueueItem ... | ForEach-Object Expanded | Format-Table # For mixed-queue output, pipe to Format-OrchQueueItem to group by QueueDefinitionId first. Update-TypeData -TypeName UiPath.PowerShell.Entities.QueueItem ` -MemberName Expanded -MemberType ScriptProperty -Force -Value { $p = [ordered]@{} 'Id','Reference','Status','Priority','DeferDate','DueDate','StartProcessing','EndProcessing' | ForEach-Object { $p[$_] = $this.$_ } if ($this.SpecificContent) { foreach ($k in ($this.SpecificContent.Keys | Sort-Object)) { $p[$k] = $this.SpecificContent[$k] } } [pscustomobject]$p } # Surface ReleaseName as ProcessName: ReleaseName is the API-correct name (a Release # is the deployed version of a process), but users typing Format-Table ProcessName # expect a column to appear. The alias makes both work without changing the # underlying property. Update-TypeData -TypeName UiPath.PowerShell.Entities.Job ` -MemberName ProcessName -MemberType ScriptProperty -Force -Value { $this.ReleaseName } # Argument completers for the folder property cmdlets on Orchestrator drives. A folder exposes # exactly one settable property -- Description -- so: # Set/Get/Clear-ItemProperty <Orch folder> -Name <Tab> -> Description # Set-ItemProperty <Orch folder> -Name Description -Value <Tab> -> the folder's current Description # These register on the BUILT-IN cmdlets (global), so for any non-Orchestrator path we return # nothing: PowerShell then falls back to its existing/native completion, leaving FileSystem, # Registry, and every other provider completely unaffected (an empty result restores the default). Register-ArgumentCompleter -CommandName Set-ItemProperty,Get-ItemProperty,Clear-ItemProperty -ParameterName Name -ScriptBlock { param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) $path = $fakeBoundParameters['LiteralPath']; if (-not $path) { $path = $fakeBoundParameters['Path'] } if (-not $path) { return } if ($path -match '^\s*([^:\\/]+):') { $drive = $Matches[1] } else { $drive = (Get-Location).Drive.Name } if ($drive -notin (Get-PSDrive -PSProvider UiPathOrch -ErrorAction SilentlyContinue).Name) { return } if ('Description' -like "$wordToComplete*") { [System.Management.Automation.CompletionResult]::new( 'Description', 'Description', 'ParameterValue', "The folder's Description (its only settable property)") } } Register-ArgumentCompleter -CommandName Set-ItemProperty -ParameterName Value -ScriptBlock { param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) $path = $fakeBoundParameters['LiteralPath']; if (-not $path) { $path = $fakeBoundParameters['Path'] } if (-not $path) { return } if ($path -match '^\s*([^:\\/]+):') { $drive = $Matches[1] } else { $drive = (Get-Location).Drive.Name } if ($drive -notin (Get-PSDrive -PSProvider UiPathOrch -ErrorAction SilentlyContinue).Name) { return } if ("$($fakeBoundParameters['Name'])" -ne 'Description') { return } $desc = (Get-Item -LiteralPath $path -ErrorAction SilentlyContinue).Description if ([string]::IsNullOrEmpty($desc)) { return } # Offer the current value (single-quoted, doubled inner quotes) so it can be edited in place. $literal = "'" + ($desc -replace "'", "''") + "'" [System.Management.Automation.CompletionResult]::new($literal, $desc, 'ParameterValue', $desc) } |