< Back

New-OMSDataInjection

Sat Jan 18, 2020 5:49 pm

NAME New-OMSDataInjection



SYNOPSIS







SYNTAX

New-OMSDataInjection -OMSConnection <Object> -LogType <String> -UTCTimeStampField <String> -OMSDataJSON <String>

[<CommonParameters>]



New-OMSDataInjection -OMSConnection <Object> -LogType <String> -UTCTimeStampField <String> -OMSDataObject

<PSObject> [<CommonParameters>]



New-OMSDataInjection [-OMSWorkSpaceId] <String> -PrimaryKey <String> [-SecondaryKey <String>] -LogType <String>

-UTCTimeStampField <String> -OMSDataJSON <String> [<CommonParameters>]



New-OMSDataInjection [-OMSWorkSpaceId] <String> -PrimaryKey <String> [-SecondaryKey <String>] -LogType <String>

-UTCTimeStampField <String> -OMSDataObject <PSObject> [<CommonParameters>]





DESCRIPTION

Injecting custom data into Microsoft Operations Management Suite (OMS) Log Analytics using its HTTP Data Collector

API.





PARAMETERS

-OMSConnection <Object>

OMSWorkSpace Azure Automation Connection object



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-LogType <String>

Specify the OMS log type. This value can be searched in OMS using the 'Type' keyword.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-UTCTimeStampField <String>

Please specify a field in the JSON or PSObject input what contains the time stamp to be used by OMS. Please

ensure UTC time is used. This field can either contain a string that can be translated to a datetime object

using [datetime]::parse() method, or a datetime value.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-OMSDataJSON <String>

A JSON formatted string that contains the log to be injected in OMS



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-OMSDataObject <PSObject>

a PSObject that contains data to be injected in OMS



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-OMSWorkSpaceId <String>

The Id of the OMS Workspace. This value can be found in the your OMS workspace under Settings -> Connected

Sources



Required? true

Position? 0

Default value

Accept pipeline input? false

Accept wildcard characters? false



-PrimaryKey <String>

The primary key of the OMS Workspace. This value can be found in the your OMS workspace under Settings ->

Connected Sources



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-SecondaryKey [<String>]

The secondary key of the OMS Workspace. This value can be found in the your OMS workspace under Settings ->

Connected Sources. This value is optional, however, if specified, the module will try to use this key to

authenticate if the primary key has failed authentication.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

None







OUTPUTS

System.Object







-------------------------- EXAMPLE 1 --------------------------



PS C:\\>$PrimaryKey = Read-Host -Prompt 'Enter the primary key'

$ObjProperties = @{

Computer = $env:COMPUTERNAME

Username = $env:USERNAME

Message = 'This is a test message injected by the OMSDataInjection module. Input data type: PSObject'

LogTime = [Datetime]::UtcNow

}

$OMSDataObject = New-Object -TypeName PSObject -Property $ObjProperties

$InjectData = New-OMSDataInjection -OMSWorkSpaceId '8fb61d08-12ac-400a-a45b-0e607994779f' -PrimaryKey $PrimaryKey

-LogType 'OMSTestData' -UTCTimeStampField 'LogTime' -OMSDataObject $OMSDataObject



Injecting data using a PS object by specifying the OMS workspace Id and primary key

-------------------------- EXAMPLE 2 --------------------------



PS C:\\>$OMSConnection = Get-AutomationConnection 'OMSConnection'

$OMSDataJSON = @"

{

"Username": "administrator",

"Message": "This is a test message injected by the OMSDataInjection module. Input data type: JSON",

"LogTime": "Tuesday, 28 June 2016 9:08:15 PM",

"Computer": "SERVER01"

}

"@

$InjectData = New-OMSDataInjection -OMSConnection $OMSConnection -LogType 'OMSTestData' -UTCTimeStampField

'LogTime' -OMSDataJSON $OMSDataJSON



Injecting data using JSON formatted string by specifying the OMSWorkspace Azure Automation / SMA connection object

(to be used in a runbook)

-------------------------- EXAMPLE 3 --------------------------



PS C:\\>$PrimaryKey = Read-Host -Prompt 'Enter the primary key'

$arrOMSDataObjects = @()

$ObjProperties1 = @{

Computer = $env:COMPUTERNAME

Username = $env:USERNAME

Message = 'This is test message #1 injected by the OMSDataInjection module. Input data type: PSObject'

LogTime = [Datetime]::UtcNow

}

$OMSDataObject1 = New-Object -TypeName PSObject -Property $ObjProperties1

$arrOMSDataObjects += $OMSDataObject1



$ObjProperties2 = @{

Computer = $env:COMPUTERNAME

Username = $env:USERNAME

Message = 'This is test message #2 injected by the OMSDataInjection module. Input data type: PSObject'

LogTime = [Datetime]::UtcNow

}

$OMSDataObject2 = New-Object -TypeName PSObject -Property $ObjProperties2

$arrOMSDataObjects += $OMSDataObject2

$InjectData = New-OMSDataInjection -OMSWorkSpaceId '8fb61d08-12ac-400a-a45b-0e607994779f' -PrimaryKey $PrimaryKey

-LogType 'OMSTestData' -UTCTimeStampField 'LogTime' -OMSDataObject $arrOMSDataObjects



Injecting multiple log entries using an array of PS objects by specifying the OMS workspace Id and primary key



RELATED LINKS