Public/Export-SCOMEventsToCSV.ps1
|
Function Export-SCOMEventsToCSV { <# .SYNOPSIS Will export Operations Manager event log events to CSV .EXAMPLE Export-SCOMEventsToCSV The above example will output the newest 1000 SCOM events (default 1000) to a .CSV at C:\<computername>_OpsManEvents.csv .EXAMPLE Export-SCOMEventsToCSV -Newest 1500 -Path c:\Temp\SCOMlog.csv .NOTES Author: Tyson Paul Blog: https://monitoringguys.com/ Original Date: 2018.03.22 History: #> [CmdletBinding(DefaultParameterSetName='Parameter Set 1', SupportsShouldProcess=$true, PositionalBinding=$false, ConfirmImpact='Medium')] Param ( [int]$Newest = 1000, # Param1 help description [Parameter(Mandatory=$false, ValueFromPipeline=$false, ValueFromPipelineByPropertyName=$false, ValueFromRemainingArguments=$false, Position=1, ParameterSetName='Parameter Set 1')] [Alias("Path")] [string]$OutFileCSV = "C:\$($env:COMPUTERNAME)_OpsManEvents.csv" ) Get-EventLog -LogName 'Operations Manager' -Newest $Newest | Export-Csv -Path $OutFileCSV -NoTypeInformation -Force Return (Get-Item $OutFileCSV) } |