diff --git a/tools/collector-generator/New-Collector.ps1 b/tools/collector-generator/New-Collector.ps1 index a0771198..d926d277 100644 --- a/tools/collector-generator/New-Collector.ps1 +++ b/tools/collector-generator/New-Collector.ps1 @@ -2,9 +2,22 @@ Param( [Parameter(Mandatory=$true)] $Class, [Parameter(Mandatory=$false)] - $CollectorName = ($Class -replace 'Win32_PerfRawData_Perf','') + $CollectorName = ($Class -replace 'Win32_PerfRawData_Perf',''), + [Parameter(Mandatory=$false)] + $ComputerName = "localhost", + [Parameter(Mandatory=$false)] + $Credential ) -$members = Get-WMIObject $Class ` +$ErrorActionPreference = "Stop" + +if($Credential -ne $null) { + $wmiObject = Get-WMIObject -ComputerName $ComputerName -Credential $Credential -Class $Class +} +else { + $wmiObject = Get-WMIObject -ComputerName $ComputerName -Class $Class +} + +$members = $wmiObject ` | Get-Member -MemberType Properties ` | Where-Object { $_.Definition -Match '^u?int' -and $_.Name -NotMatch '_' } ` | Select-Object Name, @{Name="Type";Expression={$_.Definition.Split(" ")[0]}}