Scripts/Get-BPAFolderRoot.ps1
function Get-BPAFolderRoot { <# .SYNOPSIS Gets AutoMate BPA root folders. .DESCRIPTION Get-BPAFolderRoot returns a list of root folders and their IDs. .PARAMETER Type The type of root folder to return. .EXAMPLE # Get the default system agent Get-BPAFolderRoot -Type Task .EXAMPLE # Get workflows contained in the root of \WORKFLOWS Get-BPAFolderRoot -Type Workflow | Get-BPAWorkflow .NOTES Author(s): : David Seibel Contributor(s) : Date Created : 11/08/2016 Date Modified : 02/27/2017 .LINK https://github.com/davidseibel/PoshBPA #> [CmdletBinding()] [OutputType([System.Object[]])] param( [ValidateSet("AgentGroup","Condition","Process","ProcessAgent","Task","TaskAgent","User","UserGroup","Workflow")] [string]$Type, [string]$BPAServer ) if ($BPAServer) { if ($BPAServer -notin $BPAConnectionInfo.Server) { throw "Not connected to server $BPAServer!" } $servers = @($BPAServer) } else { $servers = @($global:BPAConnectionInfo.Server) } if ($PSBoundParameters.ContainsKey("Type")) { $Types = @($Type) } else { $Types = @("AgentGroup","Condition","Process","ProcessAgent","Task","TaskAgent","User","UserGroup","Workflow") } foreach ($Type in $Types) { foreach ($server in $servers) { $result = [PSCustomObject]@{ "ID" = ([BPATypeDictionary]::$Type).RootFolderID "Name" = ([BPATypeDictionary]::$Type).RootFolderName "Path" = ([BPATypeDictionary]::$Type).RootFolderPath "TypeName" = "Folder" "BPAServer" = $server } $result.PSObject.TypeNames.Insert(0,"BPAConstructType.Folder") $result } } } |