Created
March 30, 2017 05:26
-
-
Save TheRealNoob/144c31c88a1cb5bc4a7343018be425ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Variables | |
$ComputerList = "$HOME\Desktop\computerlist.txt" | |
$SaveDestination = "$HOME\Desktop" | |
#Setup | |
$ErrorActionPreference = "SilentlyContinue" | |
#Script | |
foreach ($ComputerName in (Get-Content $ComputerList)) | |
{ | |
Get-WmiObject -Class Win32_Share -ComputerName "$ComputerName" 2>&1 | Out-Null | |
if ($? -eq "True") | |
{ | |
Write-Host Found shares `@ $ComputerName | |
Get-WmiObject -Class Win32_Share -ComputerName "$ComputerName" | Where-Object { $_.Name -NotLike "*$" } | Where-Object { $_.Path -Like "*:*" } | Format-Table | Out-File $SaveDestination\$ComputerName.txt | |
} | |
} | |
#Remove false positives | |
Write-Host "" | |
Write-Host Removing false positives | |
Get-ChildItem "$SaveDestination" | Where-Object { $_.extension -eq ".txt" } | Where-Object { $_.length -eq 0 } | Remove-Item |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment