Usinb subexpression operator in Get-CIMInstance filter This topic contains 2 replies, has 2 voices, and was last updated by Greg Tate 1 month, 2 weeks ago.Viewing 3 posts - 1 through 3 (of 3 total)Author PostsAugust 10, 2016 at 11:43 am #49812 Greg TateParticipantI'm working through the lab of advanced functions in PowerShell Toolmaking, and one of the answers to the lab questions uses the subexpression operator in the filter of Get-CimInstance. Get-CimInstance win32_process -filter "ProcessId = '$($Service.ProcessId)'" The command returns an error if I don't use the subexpression operator.Why is that?August 10, 2016 at 1:13 pm #49834 Don JonesKeymasterYou mean, if you do Get-CimInstance win32_process -filter "ProcessId = '$Service.ProcessId'" ?Because Only $service is seen as a variable. Do this:Write-Host "ProcessId = $Service.processid"And you'll see why that doesn't form a legal query. Covered this in "Learn Windows PowerShell in a Month of Lunches," FWIW.August 10, 2016 at 11:13 pm #49951 Greg TateParticipantThanks Don.This explanation clears things up. I remember you covering it in the first book, and to be honest, I have always struggled with this concept. Hoping this exercise drills it in for good now!Author PostsViewing 3 posts - 1 through 3 (of 3 total)You must be logged in to reply to this topic.