$SomeExternalFile is a very simple file with 2 columns (properties): Amount,Category. But I keep getting errors on the Where-object statement, PS saying that it doesn’t recognize “Category”.
But when I re-write the Where-object statement as:
In reading the documentation, it is not clear what/which logical comparison operators can or cannot be omitted because they have “implicit defaults”. The test for $True seems obvious. Are there any others? Is there a source of reference that clearly states which one(s) have such features? Thanking you for your attention and kind consideration.
#2 PSISContainer is positionally bound to -Name parameter of Get-Member cmdlet and fails for ‘-eq $True’ which is not valid.
#3 will also fail as PSISContainer is just an unrecognized until there is a cmdlet or function in that name.
#4 works as it resolves to the property PSISCOntainer of a FileInfo or DirectoryInfo object.
#5 works as there is a property PSISContainer and the which is having a value(finally convertible to True bool value). this Value is positionally bound to -Property parameter.
$CustomObject = [pscustomobject]@{r=1;t=0;rr=$true;tt=$false;other='something';novalue=''}
$CustomObject
$CustomObject | Get-Member -Property r #Passes as r is having 1 and is similar to $true
$CustomObject | Get-Member -Property t #Evaluates to false as t is 0 which is similar to $false
$CustomObject | Get-Member -Property rr #Passes as r is $true
$CustomObject | Get-Member -Property tt #Evaluates to false as t is $false
$CustomObject | Get-Member -Property other #Passes as other is having some value and is similar to $true
$CustomObject | Get-Member -Property novalue #Evaluates to false as novalue is empty string which is similar to $false
Get-childitem | Where-object { PSIsContainer }
PSIsContainer : The term 'PSIsContainer' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:32
+ Get-childitem | Where-object { PSIsContainer }
+ ~~~~~~~~~~~~~
Get-childitem | Get-member PSIsContainer -eq $True
Get-Member : A parameter cannot be found that matches parameter name 'eq'.
At line:1 char:42
+ Get-childitem | Get-member PSIsContainer -eq $True
+ ~~~
+ CategoryInfo : InvalidArgument: (:) [Get-Member], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetMemberCommand
But there is a short form of where-object that would work. (But you can’t do “get-childitem | where-object -not psiscontainer”.)