Last active
December 25, 2018 06:47
-
-
Save drmohundro/5a131d7ff6f291a33334 to your computer and use it in GitHub Desktop.
PowerShell functions to start/stop IIS Express in the specified directory as a background job
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$jobName = 'IisExpressJob' | |
function Start-IisExpress($pathToSource) { | |
Start-Job -Name $jobName -Arg $pathToSource -ScriptBlock { | |
param ($pathToSource) | |
& 'C:\Program Files (x86)\IIS Express\iisexpress.exe' /port:1234 /path:$pathToSource | |
} | |
} | |
function Stop-IisExpress { | |
Stop-Job -Name $jobName | |
Remove-Job -Name $jobName | |
} |
Stop-IISExpress is not stopping website which is started by Start-IISExpress , Any clue?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Slightly modified functions that checks for the jobname if it exists, and also parses arguments as parameters - just if it is usefull
Function Start-IISExpress (
[Parameter(Mandatory=$true)][string]$port = "8080",
[Parameter(Mandatory=$true)][string]$path,
[Parameter(Mandatory=$true)][string]$jobName = "IISExpressJob",
[Parameter(Mandatory=$false)][string]$iisExpressExe = "C:\Program Files\IIS Express\iisexpress.exe"
)
{
if ( [bool](get-job -Name $jobName -ea silentlycontinue) )
{
Stop-IISExpress -JobName $jobName
}
}
Function Stop-IISExpress(
[Parameter(Mandatory=$true)][string]$jobName = "IISExpressJob"
)
{
if ( [bool](get-job -Name $jobName -ea silentlycontinue) )
{
Stop-Job -Name $jobName
Remove-Job -Name $jobName
}
}