Splunk Search

Powershell vs WMI

jip31
Motivator

Hi

I an SPL command i use the Win32_DesktopMonitor WMI class and SPLUNK is able to use all the fields corresponding to this class
But i would prefer to do it with PowerShell but the script display any fiels (it works perfectly alone)
Find below what i have done :
COMMAND OR SCRIPT PATH
. "$SplunkHome\etc\apps\Splunk_TA_windows\bin\videosignal.ps1"
CRON
*/1 * * * *
SOURCETYPE
powershell:videosignal

POWERSHELL SCRIPT:
$strComputer = "."

$objWMi = get-wmiobject -computername localhost -Namespace root\CIMV2 -Query "Select * from Win32_DesktopMonitor"

foreach ($obj in $objWmi)
{
write-host "Availability:" $obj.Availability
write-host "Bandwidth:" $obj.Bandwidth
write-host "Caption:" $obj.Caption
write-host "ConfigManagerErrorCode:" $obj.ConfigManagerErrorCode
write-host "ConfigManagerUserConfig:" $obj.ConfigManagerUserConfig
write-host "CreationClassName:" $obj.CreationClassName
write-host "Description:" $obj.Description
write-host "DeviceID:" $obj.DeviceID
write-host "DisplayType:" $obj.DisplayType
write-host "ErrorCleared:" $obj.ErrorCleared
write-host "ErrorDescription:" $obj.ErrorDescription
write-host "InstallDate:" $obj.InstallDate
write-host "IsLocked:" $obj.IsLocked
write-host "LastErrorCode:" $obj.LastErrorCode
write-host "MonitorManufacturer:" $obj.MonitorManufacturer
write-host "MonitorType:" $obj.MonitorType
write-host "Name:" $obj.Name
write-host "PixelsPerXLogicalInch:" $obj.PixelsPerXLogicalInch
write-host "PixelsPerYLogicalInch:" $obj.PixelsPerYLogicalInch
write-host "PNPDeviceID:" $obj.PNPDeviceID
write-host "PowerManagementCapabilities:" $obj.PowerManagementCapabilities
write-host "PowerManagementSupported:" $obj.PowerManagementSupported
write-host "ScreenHeight:" $obj.ScreenHeight
write-host "ScreenWidth:" $obj.ScreenWidth
write-host "Status:" $obj.Status
write-host "StatusInfo:" $obj.StatusInfo
write-host "SystemCreationClassName:" $obj.SystemCreationClassName
write-host "SystemName:" $obj.SystemName
write-host
write-host "########"
write-host
}

Could you help me please??

Tags (1)
0 Karma

ansif
Motivator

Need clarification. The above powershell scripts is not working?

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...