PowerShell accessing remote machine

Challenges

The remote machine is running under Workgroup not as a Domain. The software updates such as Adobe Acrobat needs to  be updated manually due to the current standard user credential won’t let the system to install it (UAC) and it required Administrator account to login and run. The administrator has to logon every machine manually and run it the updates. The updates sometimes ran every week.

Solution

 

On the Remote machine

Start Windows PowerShell as an Administrator by right-clicking the Windows PowerShell shortcut and selecting Run as Administrator

At the PowerShell prompt, verify the WinRM is running by using the following command:

get-service winrm

The value of the Status property in the output should be Running.

To configure WIndows PowerShell for remoting, type the following command:

Enable-PSRemoting -force

If the remote computer is not in a trusted domain, the remote computer might not be able to authenticate the credentials. To enable to authentication, it requires to add the remote computer to the list of trusted host for the local machine in WinRM. To do so, type:

winrm set winrm/config/client ‘@{TrustedHosts=”LocalComputer”}’

On the local machine

Start Windows PowerShell as an Administrator by right-clicking the Windows PowerShell shortcut and selecting Run as Administrator

Run the following command:

winrm set winrm/config/client ‘@{TrustedHosts=”RemoteComputer”}’

or

winrm set winrm/config/client ‘@{TrustedHosts=”*”}’

Exit from this application.

Run Windows PowerShell ISE as Administrator

Create Untitled.ps1 document and save it under: C:\Users\Username\Documents

$Credentials = Get-Credential
Enter-PSSession -ComputerName RemoteComputer -Credential $Credentials

Run hostname to verify local machine

Run the Untitled.ps1 command with authentication window

Run hostname to verify that on remote machine

Capture

 

 

Environment

  1. Remote machine: Ms Windows 7 Professional
  2. Local machine: Ms Windows 7 Professional
  3. Network: Workgroup NOT domain
Share this: