Public/Get-MIACustomScript.ps1
function Get-MIACustomScript { [CmdletBinding(DefaultParameterSetName='List')] param ( [Parameter(Mandatory, ParameterSetName='Detail')] [string]$ScriptId, [Parameter(Mandatory=$false, ParameterSetName='List')] [string]$Name, [Parameter(Mandatory=$false, ParameterSetName='List')] [ValidateSet('ID','Name','Description','Source', 'Lang', IgnoreCase = $false)] [string[]]$Fields, [Parameter(Mandatory=$false, ParameterSetName='List')] [int32]$Page, [Parameter(Mandatory=$false, ParameterSetName='List')] [int32]$PerPage, [Parameter(Mandatory=$false, ParameterSetName='List')] [switch]$IncludePaging, # Context [Parameter(Mandatory=$false)] [ValidateNotNullOrEmpty()] [string]$Context = $script:DEFAULT_CONTEXT ) try { # Set the resource for this request $resource = "customscripts" # Send the request and write the response switch ($PSCmdlet.ParameterSetName) { 'Detail' { Invoke-MIARequest -Resource "$resource/$ScriptId" -Context $Context | Write-MIAResponse -TypeName 'MIACustomScript' } 'List' { $query = @{} switch ($PSBoundParameters.Keys) { Name { $query['name'] = $Name } Fields { $query['fields'] = $Fields -join ',' } Page { $query['page'] = $Page } PerPage { $query['perPage'] = $PerPage } } Invoke-MIARequest -Resource "$resource" -Context $Context -Body $query | Write-MIAResponse -Typename "MIACustomScript" -IncludePaging:$IncludePaging } } } catch { $PSCmdLet.ThrowTerminatingError($PSItem) } } |