Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

How to handle a Piped in property string that contains Parentheses?

$
0
0

Hi, 

I am trying to pipe a command into the "where-object" cmdlet  that has had a couple of its properties renamed to a label like "size(GB)".  The problem is that when I try to use that object property in a comparison.. I can't seem to escape out the Parentheses charcter:

PS C:\Users\v-jgree\Documents\Powershell> Get-WMIObject Win32_LogicalDisk -filter "DeviceID = 'd:' " -computer (get-content C:\Users\v-jgree\Documents\Powersh
ell\computers.txt) -Credential redmond\OtherCredentials | Select SystemName,DeviceID,VolumeName,@{Name=”size(GB)”;Expression={"{0:N1}” -f($_.size/1gb -as [int])}},@{Name
=”freespace(GB)”;Expression={"{0:N1}” -f($_.freespace/1gb -as [int])}} | Where-Object {$_size(GB) -gt 100}

I've tried both the '\'  and `  escape charcters.... but where-object does not work.   I've verified that everything works up to the Where-Object part.

what can I do?


Viewing all articles
Browse latest Browse all 8583

Trending Articles