Powershell: scan for computername prefix xyz


Is there a way to use https://www.powershelladmin.com/wiki/Port_scan_subnets_with_PSnmap_for_PowerShell#Screenshot_examples_of_PSnmap
psnmap for powershell and scan to computername prefixxyz so it would scan


Please advise.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
no it needs an array of computernames
you may want to use
$computers = get-adcomputer -filter * | where-object  {$_.Name -like "PC*"}| select-object -expandproperty Name
psnmap -computer $computers

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
A limitation of just a prefix "prefixxyz" is really too broad, and I'm quite certain that the script can't handle it.
But if your list of machines is just a number after the prefix (like in your examples "prefixxyz01","prefixxyz02", etc.), then you could easily generate this list of machines beforehand and supply that list to the script's -computername parameter.
For example:
$comps = 0..99 | % { "{0:00}" -f $_ }
.\psnmap.ps1 -computername $comps

Open in new window

David's solution is the way to go when you have a source (like ActiveDirectory) that will have all your potential hosts.  If you were in a peer-to-peer situation, or scanning hosts which you couldn't pull their names from a masterlist, then I think mine is the way to go.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.