mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-03-01 08:06:38 +00:00
Add support for generating collectors from remote systems
This commit is contained in:
@@ -2,9 +2,22 @@ Param(
|
|||||||
[Parameter(Mandatory=$true)]
|
[Parameter(Mandatory=$true)]
|
||||||
$Class,
|
$Class,
|
||||||
[Parameter(Mandatory=$false)]
|
[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 `
|
| Get-Member -MemberType Properties `
|
||||||
| Where-Object { $_.Definition -Match '^u?int' -and $_.Name -NotMatch '_' } `
|
| Where-Object { $_.Definition -Match '^u?int' -and $_.Name -NotMatch '_' } `
|
||||||
| Select-Object Name, @{Name="Type";Expression={$_.Definition.Split(" ")[0]}}
|
| Select-Object Name, @{Name="Type";Expression={$_.Definition.Split(" ")[0]}}
|
||||||
|
|||||||
Reference in New Issue
Block a user