Skip to main content

Azure Log Analytics

AzureLogAnalytics

Log directly to a Azure Log Analytics Workspace from your script

Configuration options

OptionTypeMandatoryDefaultDescription
LevelStringNoDefault LevelDefines the lowest logging level to logged
WorkspaceIdStringYesN/AId of the Azure Log Analytics Workspace
SharedKeyStringYes$truePrimary or Secondary Key to access the Azure Log Analytics Workspace
LogTypeStringNoDefaults shown in the exampleCreates a custom LogType in Log Analytics Workspace

Example

Add-LoggingTarget -Name AzureLogAnalytics -Configuration @{
WorkspaceId = '8eda8332-16eb-400b-9f0b-6a21e1c1cf28'
SharedKey = 'w7ZhaGTDtmgxcDJlaMO2YWxza2Rqw7Z1MnlvNDd5MWRsYWpraHNsa2Rhc2Q='
LogType = "Logging"
Level = 'DEBUG'
}

Write-Log -Level 'WARNING' -Message 'Hello, Powershell!' -Body { Computer = $env:COMPUTERNAME }