Hi,
I've created the following script:
Write-Host "<prtg>" param([string]$ComputerName) $value= Get-WmiObject -Query "SELECT * FROM Win32_Processor" -ComputerName $ComputerName $LoadPercentage = $value.LoadPercentage Write-Host "<result>" Write-Host "<channel>Processor Percentage</channel>" Write-Host "<value>$LoadPercentage</value>" Write-Host "<float>1</float>" Write-Host "<showTable>1</showTable>" Write-Host "<showChart>1</showChart>" Write-Host "<unit>Go</unit>" Write-Host "<mode>Absolute</mode>" Write-Host "<warning>0</warning>" Write-Host "</result>" $value2= Get-WmiObject -Query "SELECT * FROM Win32_OperatingSystem" -ComputerName $ComputerName $FreePhysicalMemory = $value2.FreePhysicalMemory/1024 Write-Host "<result>" Write-Host "<channel>Beschikbaar Geheugen MB</channel>" Write-Host "<value>$FreePhysicalMemory</value>" Write-Host "<float>1</float>" Write-Host "<showTable>1</showTable>" Write-Host "<showChart>1</showChart>" Write-Host "<unit>Go</unit>" Write-Host "<mode>Absolute</mode>" Write-Host "<warning>0</warning>" Write-Host "</result>" $MemoryUsed = ($value2.FreePhysicalMemory/$value2.TotalVisibleMemorySize) * 100 $PercentMemoryUsed = "{0:N2}" -f $MemoryUsed $PercentMemoryUsed = $PercentMemoryUsed -replace ("," , ".") Write-Host "<result>" Write-Host "<channel>Beschikbaar Geheugen %</channel>" Write-Host "<value>$PercentMemoryUsed</value>" Write-Host "<float>1</float>" Write-Host "<showTable>1</showTable>" Write-Host "<showChart>1</showChart>" Write-Host "<unit>Go</unit>" Write-Host "<mode>Absolute</mode>" Write-Host "<warning>0</warning>" Write-Host "</result>" Write-Host "</prtg>"
When I manually specify the $ComputerName variable everything works fine. But I want to set the computername with the parameter field from the sensor. I've looked everywhere, but I can't find a working example.
I hope someone has an answer for me.
Add comment