Using PowerShell to run commands on another server
If you find yourself constantly having to log onto various servers to perform maintenance tasks, you may eventually run into something that can't be done by the Windows Admin Center, Server Manager, or any of the RSAT tools. You might need to delete a file or adjust a firewall rule. In the past, we would have fired up Remote Desktop, typed in our username and password, waited for the desktop to load in, then started Command Prompt, Windows Explorer, or any number of other mundane maintenance tasks.
With PowerShell, however, there is often no need to jump through the RDP hoops to access a server. In the same way that you can ssh
into another server to run commands with Linux, PowerShell has Enter-PSSession
, Invoke-Command
, and other commands that can be used to configure servers remotely. In this recipe, we'll go through some of these commands to show you how they can save you time in the future.
Getting ready
We...