Public/TMQL.ps1
function Invoke-TMQLStatement { <# .SYNOPSIS Executes a statement against the TMQL endpoint .DESCRIPTION This function will execute a statement written in TM query language against the REST API endpoint on a TransitionManager instance .PARAMETER TMSession The name of the TM Session to use when executing a statement .PARAMETER Statement The TMQL staement to be executed .EXAMPLE "find Device by 'Name' ate '$Server1|$Server2' fetch 'id'" | Invoke-TMQLStatement -TMSession TMAD60 .EXAMPLE $Statement = @" find Person by \ 'email' eq 'sowen@tdsi.com' \ fetch 'id', 'email', 'firstName', 'lastName' "@ Invoke-TMQLStatement -TMSession TMAD60 -Statement $Statement .OUTPUTS A PSCustomObject containing the results of the statement execution #> [CmdletBinding()] param ( [Parameter(Mandatory = $false, Position = 1)] [PSObject]$TMSession = 'Default', [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] [String]$Statement ) begin { $TMSession = Get-TMSession $TMSession $bodyParams = @{ statement = $Statement } } process { Invoke-TMRestMethod -Api tmql/statement -Method Get -BodyParams $bodyParams } } |