- Function RetrieveIDs()
- {
- Param ([String] $MPName, [String]$Path)
- If ($Path -eq "") { $Path=("C:\Temp") }
- $MonitorsFile = $Path + "\MonitorsIds.csv"
- $RulesFile = $Path + "\RulesIds.csv"
- "Files MonitorsIds.csv & RulesIds.csv will be generated in : " + $Path
- If ($MPName -eq "") { $MPName=(Read-Host "Enter a Management Pack Name ") }
- $mp=Get-ManagementPack | where {$_.name -eq $MPName}
- if ($mp -eq $null) {
- "The ManagementPack you have put in argument is incorrect or not found"
- "Here is a list of available MP:"
- Get-ManagementPack | sort -property Name | ft Name
- break
- }
- $mp.Getmonitors() | select DisplayName, XMLTag,Category,Name,id, @{name="Description";expression={foreach-object {$_.Description -replace "\n","-"}}} | export-csv -noTypeInformation -path $MonitorsFile
- $mp.Getrules() | select DisplayName, XMLTag,Category,Name,id, @{name="Description";expression={foreach-object {$_.Description -replace "\n","-"}}} | export-csv -noTypeInformation -path $RulesFile
- }
- Just launch the command with no parameter:
No cvs files will be created since no MP Name is given. The output of the script will be the list of available MP.
- Launch the command with 1 parameter that should be a MP Name:
The cvs files MonitorsIds.csv & RulesIds.csv will be created in the default folder that is C:\Temp. You will retrieve information for the rules and monitors for the MyMPName MP.
- Launch the command with 2 parameter that should be a MP Name and the path where to create the files :
The cvs files MonitorsIds.csv & RulesIds.csv will be created in the C:\MyPath folder. You will retrieve information for the rules and monitors for the MyMPName MP.
This posting is provided "AS IS" with no warranties.
No comments:
Post a Comment