Discovery step powershell script error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2022 03:05 AM
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 $ & + ?
- Labels:
-
Discovery

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2022 11:45 PM
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