If it's acceptable to terminate the server when the PowerShell session exits, use a background job:
In PowerShell (Core) 7+
ng server &
In Windows PowerShell, explicit use of Start-Job
is required:
Start-Job { ng server }
Both commands return a job-information object, which you can either save in a variable ($jb = ...
) or discard ($null = ...
)
If the server process produces output you'd like to monitor, you can use the Receive-Job
cmdlet.
See the conceptual about_Jobs topic for more information.
If the server must continue to run even after the launching PowerShell session exits, use the Start-Process
cmdlet, which on Windows launches an independent process in a new console window (by default); use the -WindowStyle
parameter to control the visibility / state of that window:
Start-Process ng server # short for: Start-Process -FilePath ng -ArgumentList server
Note: On Unix-like platforms, where Start-Process
doesn't support creating independent new terminal windows, you must additionally use nohup
- see this answer.