function Ping-AlkamiWebSitesExtended { <# .SYNOPSIS Warms up web tier web services #> [CmdletBinding()] [OutputType([System.Object])] Param( # This can be used to consume the output as an object in a downstream function # If not included the output is formatted for review by a human [Parameter(Mandatory = $false)] [Alias("NoOutput")] [switch]$skipOutput, [Parameter(Mandatory = $false)] [Alias("SkipServerCheck")] [switch]$skipCheck, [array]$endpoints = @("AcculynkP2PSSO", "ACHPayments", "API", "Applications", "Authentication", "AutoBooksSSO", "AvokaSso", "Azigio", "BaxterVCA", "Benefits", "BenefitsBCU", "BillPay", "BillpayV2", "BizCardz", "Budgets", "BusinessACH", "BusinessAdmin", "BusinessAdministration", "BusinessReports", "BusinessWires", "CalculatorCalendar", "CardManagement", "CardManagementV2", "CardRewards", "CardWorks", "Cashback", "CashEdge", "CenlarMortgage", "CheckFreeBillPay", "CheckFreeBusinessSSO", "CheckFreeSSOV2", "Content", "CourtesyPay", "CourtesyPayV2", "COWWW", "CUBUSEStatementAlert", "CUBUSLoyaltyChecking", "CUBUSRewards", "CUBUSSkipAPay", "CubusSkipAPaySSO", "CUDL", "CunexusLoanEngine", "Dashboard", "DashboardV2", "DFCUApplications", "DirectDeposit", "Dispute", "DMIMortgage", "DpxPay", "DraftServices", "DSCardOrder", "DSCMNDonations", "DSCopyRequest", "DSEStatements", "DSMarketingEmail", "DSPrivilegePay", "DSSkipAPay", "DYOC", "eDocs", "EDocuments", "EnsentaSSO", "FicoScore", "FICSMortgage", "FISSSO", "FISSSOV2", "Forms", "FuegoCardManagement", "FuegoLoan", "Geezeo", "GenericUrlLaunch", "HighQSavings", "IMSI", "ImsiSso", "InstantOpen", "InstantOpenSSO", "Investments", "IPay", "IPAYSSOV2", "Iris", "KaneSecureForms", "LaserTec", "LoanCoupon", "Locations", "MasterCardRewards", "MemberServices", "MeridianLink", "MessageCenter", "MoveMoney", "MyAccounts", "MyAccountsV2", "MyCardInfo", "Oauth", "OauthExtensionExample", "oFlows", "OpenAnywhere", "OracleKnowledgeBase", "ORCASInvestments", "OverdraftProtectionPriority", "Payroll", "PcusCallback", "PFCULoanApplications", "PointsForPerks", "PositivePayACHAlert", "ProfitStarsCommercialRDC", "ProfitStarsRDC", "ProPay", "PSCUAccessPoint", "PscuBillPay", "PSCUMFoundryEnrollment", "PSCURewards", "QBO", "QuickApply", "QuickApps", "QuickWires", "QuorumSecureForms", "QuorumSecureFormsFormsAndServices", "QuorumSecureFormsOnlineDeposits", "QuorumSecureFormsOpenNewAccounts", "QuorumSecureFormsWireTransfers", "RemoteDeposit", "ResearchAndPlanning", "RetailWires", "RewardsMacu", "RewardsNow", "RTSRewards", "SavingsGoals", "SavvyMoney", "Settings", "SkipAPay", "SkipAPayV2", "STCUBalanceTransfer", "STCULending", "StudentChoiceLoan", "Swbc", "Sweeps", "SymAppSSO", "SymitarLoans", "TeleSignCallBack", "Transfer", "TransferV2", "UChooseRewards", "uOpen", "UpdateSecurityCode", "UserServices", "USFBenefits", "Vantiv", "VertifiDeposZipSSO", "VirtualCapture", "YodleeSSO" ) ) Add-Type -Path (Get-ChildItem -Path "C:\Windows\assembly\" -Include "Microsoft.Web.Administration.dll" -Recurse).FullName $logLead = (Get-LogLeadName); if ((Test-IsAppServer) -and !($skipCheck.IsPresent)) { # Exit Early Write-Host ("$logLead : This is not a valid function for an app server") return } $siteArray = @() $testPattern = "text/javascript" $maxJobs = 15 $jobs = @() $mgr = New-Object Microsoft.Web.Administration.ServerManager $functionStopWatch = [System.Diagnostics.Stopwatch]::StartNew() $sites = $mgr.Sites | Where-Object {$_.State -eq "Started"} | Where-Object {$_.Applications["/"].VirtualDirectories["/"].PhysicalPath -notlike "*IPSTS" -and $_.Name -notlike "*Eagle*" -and $_.Name -notlike "*admin*" -and $_.Name -ne "Default Web Site"} $sites = @($sites); if (@($sites).Length -eq 0) { Write-Warning "$logLead : No sites were found to install!!"; Write-Warning "$logLead : Please make sure the ConfigurationValues.ps1 got updated correctly!!"; return; } $sites | ForEach-Object { $httpBinding = $_.Bindings | Where-Object {$_.Protocol -like "https"} | Select-Object -First 1 if ($null -eq $httpBinding) { Write-Warning ("$logLead : Could not find any https binding for site {0}" -f $_.Name) } else { $hostName = "localhost" if ($httpBinding.Protocol -eq "https") { $hostName = $httpBinding.Host } $urlString = "{0}://{1}" -f $httpBinding.Protocol, $hostName, $_.Name # Add Site to Cover CUFX / ORBFX / Mobile Auth $siteArray += @{Name = $_.Name; Url = $urlString; Ipsts = $false; Admin = $false; Client = $true} $cleanUrl = $urlString.TrimEnd("/") foreach ($endpoint in $endpoints){ $siteArray += @{Name = $_.Name; Url = ($cleanUrl + "/$endpoint"); Ipsts = $false; Admin = $false; Client = $true} } } } $scriptBlock = { param ($site, $testPattern) try { add-type @" using System.Net; using System.Security.Cryptography.X509Certificates; public class TrustAllCertsPolicy : ICertificatePolicy { public bool CheckValidationResult( ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem) { return true; } } "@ [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy $stopWatch = [System.Diagnostics.Stopwatch]::StartNew() $response = Invoke-WebRequest -Uri $site.Url -UseBasicParsing $stopWatch.Stop() if ($response.StatusCode -ne 200 -or $response.Content -notmatch $testPattern) { return New-Object -TypeName PSObject -Property @{ Name = $site.Name URL = $site.Url.ToLowerInvariant() Success = $false StatusCode = $response.StatusCode Elapsed = $stopWatch.Elapsed.ToString() } } else { return New-Object -TypeName PSObject -Property @{ Name = $site.Name URL = $site.Url.ToLowerInvariant() Success = $true StatusCode = "200" Elapsed = $stopWatch.Elapsed.ToString() } } } catch { return New-Object -TypeName PSObject -Property @{ Name = $site.Name URL = $site.Url.ToLowerInvariant() Success = $false StatusCode = "Error" Elapsed = $stopWatch.Elapsed.ToString() } } } $siteResults = @() Write-Host ("$logLead : Starting Site Warmup") foreach ($site in $siteArray) { $jobs += Start-Job -ScriptBlock $scriptBlock -ArgumentList $site, $testPattern $running = @($jobs | Where-Object {$_.State -eq 'Running'}) while ($running.Count -ge $maxJobs -and $running.Count -ne 0) { (Wait-Job -Job $jobs -Any) | Out-Null $running = @($jobs | Where-Object {$_.State -eq 'Running'}) } } Wait-Job -Job $jobs > $null $failed = @($jobs | Where-Object {$_.State -eq 'Failed'}) if ($failed.Count -gt 0) { $failed | ForEach-Object { $_.ChildJobs[0].JobStateInfo.Reason.Message } } $jobs | ForEach-Object { $siteResults += $_ | Receive-Job | Select-Object URL, Success, StatusCode, Elapsed } $functionStopWatch.Stop() if ($skipOutput) { return $siteResults } else { if ($null -ne ($siteResults | Where-Object {$_.Success -eq $false})) { Write-Warning ("$logLead : One or more URLs failed the test case:`n") } $siteResults | Format-Table -Property @{Label = "URL"; Width = 70; e = {$_.URL}; Alignment = "Left"}, @{Label = "Success"; Width = 15; e = {$_.Success}; Alignment = "Right"}, @{Label = "Elapsed"; Width = 25; e = {$_.Elapsed}; Alignment = "Right"} | Out-String Write-Output ("$logLead : Total Execution Time: {0}" -f $functionStopWatch.Elapsed.ToString()) } }