I want to write a PS script, that would go through all machines it can find on a local network, take a look at "SomeDirectory" and if a file there exists, overwrite it with a new version for a UNC path..
The First problem is getting a list of PC's that you can find in Windows -> Network
There is no specific PowerShell cmdlet or script to fetch all computers accounts in a specific Active Directory (AD) domain. You will have to use the Get-ADComputer cmdlet, and use the right parameters and filters to get the desired list of AD computer accounts.
We can get a list of all computers in Active Directory using the Powershell cmdlet Get-ADComputer. The Get-ADComputer cmdlet supports SQL like filter and LDAP filter to filter AD computers.
Enter the PowerShell system info commandType Get-ComputerInfo and press “Enter”. It will return all of your system specifications, from the Windows version to Bios data.
The Get-NetAdapter cmdlet gets the basic network adapter properties. By default only visible adapters are returned. To see the common network adapter properties, pipe the output into the Format-List cmdlet.
Soemtimes the old school way is the easiest.
net view
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.).
Here's another thing you can do (depending on your worgroup name).
([adsi]"WinNT://WORKGROUP").Children
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With