Applying a "filter" on the Get-ADComputer Powershell Command
<p>In short, what I'm trying to do is, run a command that will capture the names of a set of computers and then output the results into a text file. Note how I said a "set of computers", for this, I am aware that a filter must be applied. I have applied a filter, but the output file literally outputs blank! </p>

<p>See my code below:</p>

<pre><code>Get-ADComputer -Filter { Name -eq "GBSU1" } | select Name | out-file C:\Users\adm-arifsohm\Desktop\test-folder\computers.txt
</code></pre>

<p>Can someone please tell me what I am doing wrong?</p>

<p><strong>Update:</strong></p>

<p>I was able to work it out in the end. Please see my revised code:</p>

<pre><code>Get-ADComputer -Filter {(Name -like 'GBSU-*') -or (Name -like 'GBSU1*')} | Select -Expand Name | out-file C:\Users\adm-arifsohm\Desktop\test-folder\computers.txt
</code></pre>

<p>Thanks to all who helped.</p>