Add support for generating collectors from remote systems

This commit is contained in:
Calle Pettersson 2017-03-03 14:55:11 +01:00
parent b4ca3412dd
commit 9ea0c95ca5
1 changed files with 15 additions and 2 deletions

View File

@ -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]}}