#Tony Unger
#Tonyunger.com
#Scans all AD servers for Shares
#50 servers at a time
#Will Prompt for creds
$i =0
import-module activedirectory
cls
$creds = Get-Credential
$myCol = @()
$Domain = "microsoft.com"
$Servers = Get-ADComputer -server $Domain -Filter {(OperatingSystem -Like "Windows Server*")-and (enabled -eq "true")} -Property SamAccountName | Select -expand Name
$scriptblock = {
param(
[string]$server,
$creds
)
Get-WmiObject Win32_Share -ComputerName $server -Credential $Creds | select *
}
foreach($server in $Servers){
$i++
$running = @(Get-Job | Where-Object { $_.State -eq 'Running' })
Write-Progress -Activity "Gathering computer info" -status "Currently on $server -- $i of $Servers.count" -percentComplete ($i / $Servers.count*100)
if ($running.Count -le 50) {
Start-Job -ScriptBlock $scriptblock -Name $server -ArgumentList $server, $creds
}
else {
$running | Wait-Job
}
}
while ($running.Count -ge 1) {
sleep 1
$running = @(Get-Job | Where-Object { $_.State -eq 'Running' })
}
foreach ($job in Get-Job ){
$recjobs = Receive-Job -Keep -Job $job
foreach ($recjob in $recjobs){
$Detail = New-Object PSObject
$Detail | Add-Member Noteproperty Name $recjob.name
$Detail | Add-Member Noteproperty Path $recjob.path
$Detail | Add-Member Noteproperty Server $recjob.__SERVER
$myCol += $Detail
}
}
$myCol
$myCol | export-csv -Path c:\TEMp\shares\output.csv -notype
These are just random notes and programs that may have incomplete descriptions. Any scripts or programs use at your risk
Thursday, July 9, 2015
Powershell: Jobs - Search for shares in ad windows servers
Job script to search for shares in a active directory environment.
Update $Domain to your domain and run
Subscribe to:
Comments (Atom)
Powershell: Microsoft Graph to add new roles to application registration
PowerShell Script Bulk add new roles to application registration in azure. Update $roles with ,Us...
-
Here is an excel document I created that will ping a list of nodes in column A and give results in column B. There are much better tools th...
-
#reads event logs for filter and exports to $Date = ( Get-Date ).AddMinutes(-30) $LogName = 'Security' $ProviderName = ...
-
Using Google Chrome or MS Edge: Disable Javascript post page load. 1. Open console in dev tools 2. press ctrl - alt - p 3. In the run dial...