I need clarity on a syntax issue that I don't see answered anywhere:
What are the PowerShell 5+ Filter differences in Tick and Quotes use (like in get-adcomputer)?
I find that whenever I use Filter in AD commands I get a variety of differences in syntax capability.
Like in this particular syntax I see quotes (") surrounding the whole syntax with '-and' and ticks(')
for the entries are what works.
$result = get-adcomputer -Server $LocalDomainDC -Properties * -Filter 'enabled -ne "true" -and OperatingSystem -like "*Server*"'|`
#$result.count |`
Export-CSV .\output\$day-ServersEnabledInActiveDirectory.csv -NoTypeInformation -Encoding UTF8 -Append
But then I see on Technet an answer marked as working with the REVERSE syntax on the Ticks and Quotes:
get-aduser -Server $LocalDomainDC -Properties * -Filter "enabled -ne 'true' -and Name -like '*Patrick*'"
So, what are the differences here? Why do they both work? When do we know which one to use, and why?
BTW:
I set $LocalDomainDC in my logon $profile for both PS and ISE to the
$LocalDomainDC = $env:LOGONSERVER.Remove(0,2)
Name Value
PSVersion 5.1.17763.1852
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.1852
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
