Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

foreach - if statement help

$
0
0

Hi

I'm creating a script to get names of computers in ad, pinging the clients etc.

I need some help on weeding out specific machines..

without the 'weeding out' the script looks like this: (snippet of the script)

Get-QADComputer -SearchRoot "site.dk/computere/arbejdsstationer/Windows 7/sccm/test sup sccm" | foreach `
    {
#each of them is testing for ping. if it's pinging the script continue
    if (Test-Connection $_.name -Quiet)
        {
		#Get ComputerName

		$name = $_.name

I want to weed out all ad machines returned that has a name like "V00"

but I'm unsure if I can do it in the foreach above?

Guidance needed :)


Kindest regards, Martin


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>