Hello,
I have the following script which returns me the values I want when I run it manually on the server from ad administrative PS shell.
$manufacturer = Get-WmiObject Win32_Computersystem | select manufacturer $manufacturer = $manufacturer.manufacturer $model = Get-WmiObject Win32_Computersystem | select model $model = $model.model $OS = Get-WmiObject Win32_OperatingSystem | select caption $OS = $OS.caption $age = Get-WmiObject Win32_OperatingSystem | select InstallDate $age = $age.Installdate $hostname = $env:computername $drives = get-psdrive -psprovider 'FileSystem' | select root $drives = $drives.root ForEach ($drive in $drives) {$path = $drive + "XYZ\ZYX\Plugins\startup_plugin.xml" if (test-path $path) {$startup = $path} } [xml]$XmlDocument = Get-Content $startup $databases = $xmldocument.BVSManager.StartupData.DBEntries.Database | where { $_.Server -eq $hostname} $databases = $databases.Path $DB1Name = (get-item $databases[0]).FullName $DB2Name = (get-item $databases[1]).FullName $DB1Size = (get-item $databases[0]).Length $DB2Size = (get-item $databases[1]).Length write-host "<prtg>" write-host "<result>" write-host "<channel>Make</channel>" write-host "<value>" write-host $manufacturer write-host "</value>" write-host "</result>" write-host "<result>" write-host "<channel>Model</channel>" write-host "<value>" write-host $model write-host "</value>" write-host "</result>" write-host "<result>" write-host "<channel>OS Version</channel>" write-host "<value>" write-host $OS write-host "</value>" write-host "</result>" write-host "<result>" write-host "<channel>Build Date</channel>" write-host "<value>" write-host $age write-host "</value>" write-host "</result>" write-host "<result>" write-host "<channel>DB1</channel>" write-host "<value>" write-host $DB1Name write-host "</value>" write-host "</result>" write-host "<result>" write-host "<channel>DB2</channel>" write-host "<value>" write-host $DB2Name write-host "</value>" write-host "</result>" write-host "<result>" write-host "<channel>DB1 Size</channel>" write-host "<value>" write-host $DB1Size write-host "</value>" write-host "<result>" write-host "<channel>DB2 Size</channel>" write-host "<value>" write-host $DB2Size write-host "</value>" write-host "</result>" write-host "</result>" write-host "</prtg>"
However, when I add this custom sensor, what I get as a response is simply "0 #" . What is tehe problem? If the problem is not having administrative PS shell, how can I make this happen?
Add comment