Ahh PowerShell, I still cannot fully embrace your powerful weirdness.
With normal NT command prompt I can restart my SQL Server by running =>
net stop mssqlserver & net start mssqlserver
This does not work in PowerShell, you get the usual cryptic, nonsensical and useless error message:
PS C:\> net stop mssqlserver & net start mssqlserver
Ampersand not allowed. The & operator is reserved for future use; use "&" to pass ampersand as a string.
At line:1 char:23
+ net stop mssqlserver & <<<< net start mssqlserver
+ CategoryInfo : ParserError: (:) , ParentContainsErrorRecordException
+ FullyQualifiedErrorId : AmpersandNotAllowed
Personally, I would change this error message to:
Ampersand not allowed. You can use the semi-colon instead for a command separator in PowerShell.
Ok, given this logic, then I try:
PS C:\> net stop mssqlserver "&" net start mssqlserver
The syntax of this command is:
Ok, I give up. Time to search the internet.
Found some mention of an undocumented semi-colon as command separator, this works =>
PS C:\> net stop mssqlserver ; net start mssqlserver
The SQL Server (MSSQLSERVER) service is stopping.
The SQL Server (MSSQLSERVER) service was stopped successfully.
The SQL Server (MSSQLSERVER) service is starting.
The SQL Server (MSSQLSERVER) service was started successfully.