5 PowerShell remote execution
This chapter covers
- Designing scripts for remote execution
- PowerShell-based remoting
- Hypervisor-based remoting
- Agent-based remoting
The ability to execute remote PowerShell commands is not only essential for recurring automations but is also a powerful tool to have in your arsenal for ad-hoc situations. Just think back on your career and remember times when you needed to gather large-scale information about your environment or apply a change across multiple servers at once. You will quickly realize this is a common situation for any IT department. And in some cases, especially security-related ones, time can be of the essence. Therefore, before these situations arise, you will want to have PowerShell remoting set up and know how to adapt your scripts for remote execution.
For instance, in May of 2021, security researchers identified vulnerabilities in several Visual Studio Code (VS Code) extensions. While discovering installed versions of VS Code may be simple, finding the installed extensions can present a significate challenge. This is because extensions are installed at the user level and not the system level. Therefore, a lot of scanning tools will not pick them up. Fortunately, all VS Code extensions contain a vsixmanifest file, which we can search for and read to identify installed extensions.