Powershell If statement won't accept multiple OR conditions
<p>I have a powershell script that processes a bunch of DNS A records and I'm trying to filter out the default records (i.e. "@", "ForestDNSZones", etc). Just trying this with a simple if statement doesn't seem to work.</p>

<p>Code sample:</p>

<pre><code>$zoneARecords = Get-DnsServerResourceRecord -ComputerName $DNSserver -ZoneName $zoneName | ?{$_.RecordType -eq "A"}
foreach ($record in $zoneARecords) {
    $hostName = $record.HostName
    if ($hostName -ine "gc" -or "DomainDnsZones" -or "ForestDnsZones" -or "@") {
        # Do some stuff
    }
}
</code></pre>

<p>If I shorten it down to a single condition, it works but I want all conditions met:</p>

<pre><code>if ($hostName -ine "gc")
</code></pre>

<p>If I expand out the statement so that each -or has explicit evaluations, it doesn't work:</p>

<pre><code>if ($hostName -ine "gc" -or $hostName -ine "DomainDnsZones" -or $hostName -ine "ForestDnsZones" -or $hostName -ine "@") {
</code></pre>

<p>If I just use -ne, then it doesn't work for even a single record. I have a feeling that I'm missing something simple. I've tried trimming the string to exclude trailing spaces, but that didn't work either. String length matches what it should, so there's no extraneous space problems.</p>

<p>I've thought about nesting if statements, but that seems dumb. I have used the first example of chained -or conditions in other scripts without problem.</p>

<p>Thanks in advance!</p>