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!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

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