Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

how to test remote ipconfig /flushdns script

$
0
0

Hi, i think my script is good just not sure if its actually working since there are no logs in the event viewer for flushdns command, any ideas?

"Ipconfig /flushdns script is running.."
#$servers = Get-XAServer|where {$_.servername -match "ax"}|
#select -ExpandProperty servername
$servers = Get-Content .\Servers.txt"`nLoaded total servers from file $($servers.count)`n"
$sblock = {
param($servername)
#Invoke-Command -ComputerName $servername -ScriptBlock {ipconfig /flushdns}
}
$MaxThreads = 200
$SleepTimer = 300
$jobs = @()
ForEach ($server in $servers){
#Start-Sleep -Milliseconds 200
    While ($(Get-Job -state running).count -ge $MaxThreads){
        Start-Sleep -Milliseconds $SleepTimer
    }"Sending ipconfig /flushdns to server $server"
    Start-Job -ScriptBlock $sblock -ArgumentList $server > $null"$(get-date) Sent ipconfig /flushdns to $server" >> "\\localhost\c$\PSScripts\test\CTX flushdns\lof ctx servers\flushdns.log"
}
# Wait for remaining."Waiting for jobs to finish"
Get-Job | Wait-Job > $null
Remove-Job * -Force
Write-Host "Done, Press any key to exit script..." -fore Green
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

also very rarely but when i run this script with jobs i see a lot of powershell processes just sitting in task mgr hogging up memory and taking a really long time to exit, am i using too many or is there a limit? at the moment i cant replicate this issue

Thanks


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>