Skip to content

Instantly share code, notes, and snippets.

@ChendrayanV
Last active March 6, 2018 11:05
Show Gist options
  • Save ChendrayanV/8fa63616065cf4f7b341a6762e247b79 to your computer and use it in GitHub Desktop.
Save ChendrayanV/8fa63616065cf4f7b341a6762e247b79 to your computer and use it in GitHub Desktop.
Query TrueSight Events by ID (mc_ueid)
function Get-xEventById {
[CmdletBinding()]
param (
[Parameter(Mandatory)]
$Uri,
[Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)]
$Mcueid,
[Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)]
$IMName,
[Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)]
[ValidateSet('BMCII_BUFFER_MODE_DEFAULT' , 'BMCII_BUFFER_MODE_NONE' , 'BMCII_BUFFER_MODE_LOW' , 'BMCII_BUFFER_MODE_HIGH')]
$IMBufferType
)
begin {
}
process {
try {
if ($Global:WebService -eq $null) {
$Global:WebService = New-WebServiceProxy -Uri $Uri -Namespace "xTrueSight"
}
$Connect_Request = [xTrueSight.Connect]::new()
$Connect_Request.userName = ""
$Connect_Request.password = ""
$Connect_Request.imname = $IMName
$Connect_Request.bufferType = $IMBufferType
$QueryEventById = [xTrueSight.QueryEventByID]::new()
$QueryEventById.eventId = $Mcueid
$QueryEventById.imname = $IMName
$RetrieveResult = [xTrueSight.RetrieveQueryResults]::new()
$RetrieveResult.retrieveResultHandle = $WebService.QueryEventByID($QueryEventById).resultHandle
$RetrieveResult.timeout = 0;
$RetrieveResult.num_of_events = 1
$Results = $WebService.RetrieveQueryResults($RetrieveResult)
$Disconnect = [xTrueSight.Disconnect]::new()
$Disconnect.connection = $WebService.Connect($Connect_Request).connectionId
$Disconnect.deleteBuffer = $true
[void]$WebService.Disconnect($Disconnect)
foreach ($Results in $Results.results) {
[pscustomobject]@{
event_handle = $Results.GetValue(1).value.item
mc_ueid = $Results.GetValue(2).value.item
status = $Results.GetValue(43).value.item
mc_owner = $Results.GetValue(48).value.item
}
}
}
catch {
$_.Exception
}
}
end {
}
}
$EventParameters = @{
Uri = 'http://server001:port/imws/services/ImpactManager?wsdl'
Mcueid = 'ImWebServices.1519817129112.1519817146867.1'
IMName = 'development_ts'
IMBufferType = 'BMCII_BUFFER_MODE_DEFAULT'
}
Get-xEventById @EventParameters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment