Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
March 24, 2022 01:58 am GMT

Clean temporal files from site from IIS Powershell

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 siteInvoke-Command -Session $session -ScriptBlock $block -ArgumentList $siteName#remove data pathInvoke-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

Original Link: https://dev.to/redhcp/clean-temporal-files-from-site-from-iis-powershell-3cj1

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To