Functions/Start-Nginx.ps1
function Start-TNginx { param ( [Parameter(Mandatory=$true)] [string]$NginxLocation, [string]$ProcessName ) $ErrorActionPreference = 'Stop' if(-not $ProcessName) { $ProcessName = 'nginx' } $NginxProcess = Get-Process | Where-Object {$_.ProcessName -eq $ProcessName} if($NginxProcess) { Write-NInfo $NginxProcess } else { if(-not (Test-Path $NginxLocation -PathType Container)) { throw "Cannot find $NginxLocation, please verify it!" } Set-Location $NginxLocation Start-Process .\nginx.exe -Verb RunAs $NginxProcess = Get-Process | Where-Object {$_.ProcessName -eq $ProcessName} Write-NInfo $NginxProcess } } |