-
-
Save drmohundro/5a131d7ff6f291a33334 to your computer and use it in GitHub Desktop.
$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 | |
} |
Fixed issue with the argument list getting passed to the job.
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
}
Start-Job -Name $jobName -Arg $iisExpressExe, $port, $path -ScriptBlock {
param ($iisExpressExe, $port, $path)
Start-process $iisExpressExe -ArgumentList "/port:$port /path:$path" -WindowStyle Hidden
Start-Sleep -m 1000
}
Write-Host "Site started"
}
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
}
}
Stop-IISExpress is not stopping website which is started by Start-IISExpress , Any clue?
To use, just dot source them from your
$profile
. I use a slightly customized version that doesn't require the source. Change as needed.