Link to home
Start Free TrialLog in
Avatar of janhoedt
janhoedt

asked on

Powershell: scan for computername prefix xyz

Hi,

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
prefixxyz01
prefixxyz02
prefixxyz03

etc?

Please advise.
J.
ASKER CERTIFIED SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start 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.