Scripts/Get-BPAObjectTemplate.ps1
function Get-BPAObjectTemplate { <# .SYNOPSIS Gets the type for an AutoMate BPA object. .DESCRIPTION Get-BPAObjectType returns the type for a specified object on a specified server. .PARAMETER Type The construct type - Workflow, Task etc. .PARAMETER ConditionType The condition type - Schedule, Logon, etc. .PARAMETER BPAServer The server to retrieve the object type from. This is used to determine what version the server is running. .INPUTS The following BPA object types can be modified by this function: Workflow .EXAMPLE Get-BPAObjectType -Type Workflow -BPAServer bpaserver01 .NOTES Author(s): : David Seibel Contributor(s) : Date Created : 07/10/2016 Date Modified : 02/12/2018 .LINK https://github.com/davidseibel/PoshBPA #> [CmdletBinding()] param( [Parameter(Mandatory = $true, ParameterSetName = "ByConstructType")] [ValidateNotNullOrEmpty()] [BPAConstructType]$Type, [Parameter(Mandatory = $true, ParameterSetName = "ByConditionType")] [ValidateNotNullOrEmpty()] [BPATriggerType]$ConditionType, [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string]$BPAServer ) $templatePath = (Get-Command $MyInvocation.MyCommand).Module.ModuleBase $templatePath = Join-Path -Path $templatePath -ChildPath ObjectTemplates switch ($PSCmdlet.ParameterSetName) { "ByConstructType" { $json = Join-Path -Path $templatePath -ChildPath "$Type.json" $templateType = Get-BPAObjectType -Type $Type -BPAServer $BPAServer } "ByConditionType" { $json = Join-Path -Path $templatePath -ChildPath "$($ConditionType)Condition.json" $templateType = Get-BPAObjectType -ConditionType $ConditionType -BPAServer $BPAServer } } $currentDate = Get-Date $templateObject = Get-Content -Path $json | Out-String | ConvertFrom-Json if ($templateObject.PSObject.Properties.Name -contains "___type") { $templateObject.___type = $templateType } if ($templateObject.PSObject.Properties.Name -contains "CreatedOn") { $templateObject.CreatedOn = $currentDate } if ($templateObject.PSObject.Properties.Name -contains "ModifiedOn") { $templateObject.ModifiedOn = $currentDate } if ($templateObject.PSObject.Properties.Name -contains "VersionDate") { $templateObject.VersionDate = $currentDate } return $templateObject } |