this is for ALL sites
#invoke-command -computername "HOSTNAME" -scriptblock {iisreset /STOP}
#invoke-command -computername "HOSTNAME" -scriptblock {iisreset /START} ; Start-WebSite $args[0]
this is for ONE site
Import-Module WebAdministration
$serverName = "COMPUTERNAME" #name VM
$siteName = "ELA_Client" #name site
$block = {Stop-WebSite $args[0]};
$session = New-PSSession -ComputerName $serverName
#stop site
Invoke-Command -Session $session -ScriptBlock $block -ArgumentList $siteName
#remove data path
Invoke-Command -Session $session -ScriptBlock {Get-ChildItem โPath "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\*\" | Remove-Item -Recurse -Force }
#start site
$block = {Start-WebSite $args[0]};
Invoke-Command -Session $session -ScriptBlock $block -ArgumentList $siteName
Top comments (0)
Some comments have been hidden by the post's author - find out more