Managing PowerShell Server from the Command Line
Managing PowerShell Server from the command line may be useful in various scenarios. Any operation that can be performed from the PowerShell Server UI can also be performed by passing a command line parameter to PowerShellServer.exe.
Any setting that can be specified in the UI can also be set directly in the registry.
The PowerShell Server setup can be run in silent mode without requiring user interaction.
The available command line parameters are described below:
|/S||Indicates that the installer should run in silent mode.|
|/SNO||The serial number to be used during installation. ex:
setup.exe /S /SNO=XISUB-RA1SU-XXXXX-XXXXX-XXXXX
|/PATH||The installation path if a custom path is desired. ex:
setup.exe /S /SNO=XISUB-RA1SU-XXXXX-XXXXX-XXXXX /PATH=C:\Your\Path
The silent install itself is non-blocking and the command will return immediately. The installation will continue in the background.
If required, the following command can be used to block until installation is complete:
Start-Process setup.exe -ArgumentList @("/S","/SNO=XISUB-RA1SU-XXXXX-XXXXX-XXXXX") -WaitNote: The /S install option is case sensitive. It must be specified with an uppercase letter.
PowerShell Server stores all of its settings in the registry at:
Because of this, all that is necessary for configuration is to create/modify the registry keys that correspond with the desired settings. This can easily be done in a command line environment. For example, modifying the registry to enable SCP support using PowerShell can be done like so:
$path = "HKLM:\SOFTWARE\nsoftware\PowerShell\Server\16" New-ItemProperty -Path $path -Name EnableSCP -Value 1 -ForceThis will create or modify the EnableSCP DWORD value with a value of "1". Note that the -Force parameter causes the value to be overwritten if it already exists. Otherwise, an error will be thrown indicating that the value already exists.
Of course, this is just one way to modify registry. Any method of doing so would suffice. The key point is that PowerShell Server reads the values from the registry for its configuration and all that is necessary to modify the configuration, is to change the registry values. Please refer to the documentation for a list of applicable registry settings.
Command line parameters can also be utilized to manage PowerShell Server. The following is a list of parameters applicable to PowerShellServer.exe:
|/servicestart||Starts the service. For instance:
|/servicestop||Stops the service. For instance:
|/start||Starts PowerShell Server in-process. For instance:
|/stop||Stops PowerShell Server when it is running in-process. For instance:
|/restart||Restarts PowerShell Server when it is running in-process. For instance:
|/exit||Closes the PowerShell Server process. For instance:
Note: When running PowerShell Server in-process, these command line parameters may only be used if the AdminServiceEnabled registry key is set to 1 (True).
When running PowerShell Server as a Windows service, the administration service is also available for management. This service listens by default on port 8122 (defined by the AdminServicePort registry key). The username and password to log in are automatically generated during setup, and correspond with the AdminServiceUsername and AdminServicePassword registry keys. The AdminLocalOnly registry key controls whether the administration service is accessible remotely, and is set to 1 (True) by default.
Logging in to the administration service allows the following cmdlets to be executed:
- Disconnect-PSSClient -ConnectionId <id>
We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at firstname.lastname@example.org.