PowerShell get a list of network machines

Here's another thing you can do (depending on your worgroup name).

([adsi]"WinNT://WORKGROUP").Children

Piggy-backing on Shay's answer:

([adsi]"WinNT://$((Get-WMIObject Win32_ComputerSystem).Domain)").Children

This will grab your domain or workgroup name and use that for you.


And to piggy-back even further on FoxDeploy's answer:

(([adsi]"WinNT://$((Get-WMIObject Win32_ComputerSystem).Domain)").Children).Where({$_.schemaclassname -eq 'computer'})

This will grab just the computers on the domain, not all AD objects (such as users, organizational groups, etc.).


Soemtimes the old school way is the easiest.

net view

Tags:

Powershell