Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to perform IISRESET with Powershell Script

Tags:

powershell

iis

Does anyone know how to perform IISRESET with a PowerShell script? I'm using the PowerGUI editor with PowerShell 1.0 installed on a Windows 2008 box.

like image 958
Jukeman Avatar asked Nov 03 '09 23:11

Jukeman


People also ask

How do you restart a service in PowerShell?

Start-Service (Microsoft.PowerShell.Management) - PowerShell The Start-Service cmdlet sends a start message to the Windows Service Controller for each of the specified services. If a service is already running, the message is ignored without error.

How do I navigate to IIS in PowerShell?

Start the IIS PowerShell Management Console. Click on the Start Menu - select "All Programs" - "IIS 7.0 Extensions" - "IIS PowerShell Management Console". The prompt of the new PowerShell command window is set to "IIS:" - the root of the IIS Provider namespace.


1 Answers

You can do it with the Invoke-Command cmdlet:

invoke-command -scriptblock {iisreset} 

UPDATE:

You can also simplify the command using the & call operator:

& {iisreset}

like image 69
Jim Avatar answered Sep 20 '22 18:09

Jim