# Proxy servers in format: https://<url>:<port>. Can be multiple Proxy servers used by comma separation $proxy_servers = "https://surf.proxy:8080";# , "https://server1.testproxy:8080"; # URL's to be tested thru Proxy. $urls = "https://xml28.good.com";, "https://xml29.good.com"; #,"https://xml30.good.com"; ,"https://gti01.good.com","https://www.good.com", "https://upl01.good.com", "https://ws.good.com"; # ComputerName of tested machine Write-Host "Testing script on machine: " $env:COMPUTERNAME function DoWork { # Test URL's without PROXY first foreach ($url in $urls) { TestWithoutProxy -URL $url } # Test URL's with Proxy foreach ($proxy_serv in $proxy_servers) { foreach ($url in $urls) { TestProxy -ProxyServer $proxy_serv -URL $url } } } function TestWithoutProxy { param ( [Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, Position=0)] [Alias("U")] [string]$url ) $WebClientWithoutProxy = New-Object System.Net.WebClient Write-Host -NoNewLine "Testing without proxy server " -ForegroundColor Yellow Write-Host -NoNewLine " [*] URL test without Proxy -" $url -ForegroundColor White Try { $contentWithouProxy = $WebClientWithoutProxy.DownloadString($url) Write-Host -NoNewline " [+] Opened $url successfully without Proxy" }catch { Write-Host -NoNewLine " [-] Unable to access $url without Proxy" -ForegroundColor Red } Write-Host " [*]" } function TestProxy { param ( [Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, Position=0)] [Alias("CN")][string[]]$ProxyServer, [Parameter(Position=1)] [Alias("U")] [string]$url ) $proxy = new-object System.Net.WebProxy($ProxyServer) $WebClient = new-object System.Net.WebClient $WebClient.proxy = $proxy #Write-Host "" Write-Host -NoNewLine "Testing proxy server: " $ProxyServer -ForegroundColor Yellow Write-Host -NoNewline " [*] URL test -" $url -ForeGroundColor White Try { $content = $WebClient.DownloadString($url) Write-Host -NoNewLine " [+] Opened $url successfully" -ForegroundColor Green "- Amount of chars found on website" $content.Length } catch { Write-Host -NoNewLine " [-] Unable to access $url" -ForegroundColor Red } Write-Host " [*]" } DoWorkRunning it should give you a nice, quick overview of a test.
This post was last modified on March 20, 2016 12:24
Today, I made the decision to upgrade my test environment and update the version of…
Have you ever looked at your Active Directory and wondered, "Why do I still have…
Active Directory replication is a critical process that ensures the consistent and up-to-date state of…
Hey there! Today, I wanted to introduce you to one of the small but excellent…
Active Directory (AD) is crucial in managing identities and resources within an organization. Ensuring its…
In today's digital age, the ability to create compelling and informative HTML reports and documents…