Discovery step powershell script error

Prateek Bisht
Kilo Expert

Hi, I am trying to have a custom step in one of the windows patterns which has on Powershell script to run. (the script is below)

$lastpatch = Get-WmiObject -ComputerName localhost Win32_Quickfixengineering | select @{Name="InstalledOn";Expression={$_.InstalledOn -as [datetime]}} | Sort-Object -Property Installedon | select-object -property installedon -last 1
Get-Date $lastpatch.InstalledOn -format yyyy-MM-dd

 

I am getting error while inserting this script. can someone let me know where I need to put $ & + ? 

find_real_file.png

1 REPLY 1

Richard Hine
Tera Guru
Tera Guru

Prateek,

I see a few issues with what you are trying to do, main one being you are trying to set the output of the command into a variable whilst in the command. The command should execute and then you define the parsing in Step 2 of a parse command output operation. Suggest you have a look at some other patterns to understand this.

I think you are also trying to use -ComputerName as a variable but this would be a variable that you are passing into the command.

Hope this helps,

Richard