Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recycle Application Pool using Powershell Script

I want to recycle my application pool using one-liner command which I can put in my PowerShell script. I added the following code in my PowerShell script:

Import-Module WebAdministration

$site = "Default Web Site"

$pool = (Get-Item "IIS:\Sites\$site"| Select-Object applicationPool).applicationPool

Restart-WebAppPool $pool

But I am getting an error that name IIS doesn't exist. How can I fix it?

like image 337
Rash Avatar asked Jul 11 '16 16:07

Rash


1 Answers

I like when answers are short and simple, like this...

Restart-WebAppPool (Get-Website -Name <YourSiteName>).applicationPool
like image 78
Alexander Shapkin Avatar answered Nov 08 '22 17:11

Alexander Shapkin