Skip to content

How to prepare your environment for remote PowerShell

Black and White PDQ logo
Kris Powell|October 17, 2016
Generic blog header
Generic blog header

Let's discuss getting your environment ready for using remote PowerShell, then we dive into favorite scripts.

Enabling WinRM

Usually, it’s easiest to configure WinRM with Active Directory Group Policy, but for those who wish to do it manually, these commands will help configure your machines to use WinRM by using either command prompt or PowerShell:

Command prompt or PowerShell:

winrm quickconfig -force -q

PowerShell only (See Enable-PSRemoting)

Enable-PSRemoting -Force

This will only setup the basic configuration for WinRM.

Auto Login

Sometimes we have a need to have a machine automatically login with a specific user when the machine boots up. These scripts will help get that configured. Please note that each script includes a line that will reboot the target machine.

Resolving trust relationship issues

We’ve all been there. You have a domain trust relationship issue. There are many reasons for this to fail, but it seems that the most common has to do with the machine account password. Check out these scripts to get it working again.

Fixing the secure channel with Test-ComputerSecureChannel

$Credential = Get-Credential Test-ComputerSecureChannel -Repair -Credential $Credential

Fixing the machine account password with Reset-ComputerMachinePassword

Reset-ComputerMachinePassword

Fixing Windows update service

If you’ve ever encountered an instance of the Windows Update service not running, this (very) simple script is for you. When using products that lock a machine’s settings (Deep Freeze, etc), we’ve noticed that the Windows Update service doesn’t always get set to run. This quick script will change the Windows Update service to startup Automatically and then start the service.

Set Windows Update service to Automatic and start the service (See Set-Service)

Set-Service -Name wuauserv -StartupType Automatic Start-Service -Name wuauserv

Delete and/or Copy Files

These are just quick script examples for deleting or copying files.

Getting IP Configuration Settings

Sometimes we just need a quick way to grab network adapter settings for a machine. Here are a couple of examples to do it for a machine. The first example can be used in a PDQ Deploy package or via a PDQ Inventory Remote Command. These ensure that a command is run locally on a target machine. The second example could be used from a PDQ Inventory Custom Tool or even straight up from a PowerShell window (fancy).

Black and White PDQ logo
Kris Powell

Kris was an employee at PDQ.

Related articles