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!

Shape the Future of Splunk: Join the Product Research Lab!

Join the Splunk Product Research Lab and connect with us in the Slack channel #product-research-lab to get ...

Auto-Injector for Everything Else: Making OpenTelemetry Truly Universal

You might have seen Splunk’s recent announcement about donating the OpenTelemetry Injector to the ...

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...