PowerShell Remoting — Allowing Only One Trusted Server

PowerShell Remoting — Allowing Only One Trusted Server

For years, Windows admins used WMIC (Windows Management Instrumentation Command-line) to check hardware and system details. Microsoft is now retiring WMIC because it’s old and no longer updated. Instead, they want everyone to use PowerShell, which is more secure, flexible, and future-proof.

If you use WMIC in scripts or management tools, you’ll need to move to PowerShell commands. This guide shows how to safely allow only one trusted server to run PowerShell commands remotely on another server.


Steps to allow only Server2 to access Server1

PowerShell # Enable remoting on Server1
Enable-PSRemoting -Force

PowerShell # Restrict firewall to Server2’s IP
New-NetFirewallRule -DisplayName “Allow WinRM from Server2” `
  -Direction Inbound -Protocol TCP -LocalPort 5985 `
  -RemoteAddress 192.168.1.20 -Action Allow

PowerShell # Configure TrustedHosts on Server2
Set-Item WSMan:\localhost\Client\TrustedHosts -Value “Server1”

PowerShell # Connect with credentials from Server2
Enter-PSSession -ComputerName Server1 -Credential (Get-Credential)

Security notes

  • Limit access: Restrict which accounts can use remoting with Set-PSSessionConfiguration.
  • Audit: Review logs to confirm only Server2 connects.
  • Use secure auth: Prefer Kerberos in a domain, or HTTPS with certificates outside a domain.

WMIC vs PowerShell

Feature WMIC PowerShell
Status Deprecated, removed in new Windows builds Actively supported and updated
Ease of use Simple commands, limited flexibility Rich scripting, automation, modules
Security Legacy, minimal logging Modern, with auditing and secure remoting
Remote management Basic, less secure Full remoting via WinRM, Kerberos, HTTPS
Future support None Long-term Microsoft strategy

Common WMIC to PowerShell equivalents

WMIC wmic cpu get name
PowerShell Get-CimInstance Win32_Processor | Select-Object Name
WMIC wmic memorychip get capacity, speed
PowerShell Get-CimInstance Win32_PhysicalMemory | Select-Object Capacity, Speed
WMIC wmic diskdrive get model, size
PowerShell Get-CimInstance Win32_DiskDrive | Select-Object Model, Size
WMIC wmic os get caption, version
PowerShell Get-CimInstance Win32_OperatingSystem | Select-Object Caption, Version
WMIC wmic bios get serialnumber
PowerShell Get-CimInstance Win32_BIOS | Select-Object SerialNumber
WMIC wmic nic get name, macaddress
PowerShell Get-CimInstance Win32_NetworkAdapter | Select-Object Name, MACAddress

How to fully revert PowerShell Remoting (undo all changes)

If you enabled PowerShell Remoting and want to fully undo it, follow these steps. This not only disables remoting but also removes listeners, firewall rules, and resets the LocalAccountTokenFilterPolicy.

1. Stop and disable the WinRM service

PowerShell Stop-Service WinRM
Set-Service WinRM -StartupType Disabled

2. Delete the WinRM listener

First, list current listeners; then delete the HTTP listener (port 5985). If you configured HTTPS, remove that too.

PowerShell winrm enumerate winrm/config/listener
PowerShell winrm delete winrm/config/listener?Address=*+Transport=HTTP
PowerShell winrm delete winrm/config/listener?Address=*+Transport=HTTPS

3. Disable firewall exceptions for WS-Management

Remove built-in and custom WinRM rules, including any rule you added to allow only Server2.

PowerShell Get-NetFirewallRule | Where-Object DisplayName -like “*WinRM*” | Remove-NetFirewallRule
PowerShell Remove-NetFirewallRule -DisplayName “Allow WinRM from Server2”

4. Reset LocalAccountTokenFilterPolicy to default (0)

This restores the default behavior where remote access is restricted for local administrators unless using elevated tokens.

PowerShell Set-ItemProperty -Path “HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System” -Name LocalAccountTokenFilterPolicy -Value 0

Optional: Start with Disable-PSRemoting

You can start by running the built-in disable command, then perform the manual cleanup above to fully revert.

PowerShell Disable-PSRemoting -Force

Verification checklist

  • Service: Get-Service WinRM shows Status = Stopped and StartType = Disabled.
  • Listeners: winrm enumerate winrm/config/listener returns no active listeners.
  • Firewall: Get-NetFirewallRule | Where-Object DisplayName -like "*WinRM*" returns none.
  • Registry: LocalAccountTokenFilterPolicy is set to 0.

Closing thought

WMIC is going away, but PowerShell gives you stronger tools to manage systems. By locking down remoting to a single trusted server, and by learning the PowerShell equivalents of old WMIC commands, you keep control while using modern management methods.

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you human? Please solve:Captcha