Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Import-Module NetworkLoadBalancingClusters
$CopyOrigin="C:\inetpub\wwwroot\xxxx"
$TimeOut=5
$Servers = New-Object System.Collections.ArrayList
$Servers.Add(@{Ip="xxx.xxx.xxx";Path="E:\xxxx";Urls=("/","/appx")})
$Servers.Add(@{Ip="xxx.xxx.xxx";Path="F:\xxxx";Urls=("/","/appx")})
$Servers.Add(@{Ip="xxx.xxx.xxx";Path="G:\xxxx";Urls=("/","/appx")})
$Servers.Add(@{Ip="xxx.xxx.xxx";Path="H:\xxxx";Urls=("/","/appx")})
foreach($Server in $Servers)
{
Write-Host "Starting deploy on $Server.Ip"
Write-Host "Stopping NLB cluster..."
Stop-NlbClusterNode -Hostname $Server.Ip
Start-Sleep -Second $TimeOut
Write-Host "Copying files..."
robocopy $CopyOrigin $Server.Path /S /E
Start-Sleep -Second $TimeOut
foreach($Url in $Server.Urls){
$s=$Server.Ip
Write-Host "Warming up (http://$s$Url)..."
Write-Host http://$s$Url
$request = [System.Net.WebRequest]::Create("http://$s$Url")
$response=$request.GetResponse()
$response.Close()
}
Start-Sleep -Second $TimeOut
Write-Host "Starting NLB cluster..."
Start-NlbClusterNode -Hostname $Server.Ip
Write-Host $Server.Ip
Write-Host "Done!"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment