diff --git a/tools/collector-generator/New-Collector.ps1 b/tools/collector-generator/New-Collector.ps1 index 43944386..22ef94a5 100644 --- a/tools/collector-generator/New-Collector.ps1 +++ b/tools/collector-generator/New-Collector.ps1 @@ -2,19 +2,21 @@ Param( [Parameter(Mandatory=$true)] $Class, [Parameter(Mandatory=$false)] + $Namespace = "root/cimv2", + [Parameter(Mandatory=$false)] $CollectorName = ($Class -replace 'Win32_PerfRawData_Perf',''), [Parameter(Mandatory=$false)] $ComputerName = "localhost", [Parameter(Mandatory=$false)] - $Credential + [CimSession] $Session ) $ErrorActionPreference = "Stop" -if($Credential -ne $null) { - $wmiObject = Get-CimInstance -ComputerName $ComputerName -Credential $Credential -Class $Class +if($null -ne $Session) { + $wmiObject = Get-CimInstance -CimSession $Session -Namespace $Namespace -Class $Class } else { - $wmiObject = Get-CimInstance -ComputerName $ComputerName -Class $Class + $wmiObject = Get-CimInstance -ComputerName $ComputerName -Namespace $Namespace -Class $Class } $members = $wmiObject ` @@ -22,6 +24,7 @@ $members = $wmiObject ` | Where-Object { $_.Definition -Match '^u?int' -and $_.Name -NotMatch '_' } ` | Select-Object Name, @{Name="Type";Expression={$_.Definition.Split(" ")[0]}} $input = @{ + "Namespace"=$Namespace; "Class"=$Class; "CollectorName"=$CollectorName; "Members"=$members