Devoted to Virtualization Technologies

Site to share knowledge about VMware and related Technologies

Running Powershell cmdlets on remote computer

I am still new to powershell everyday I learn something new about it. Today, while going through the manuals, I noticed a interesting cmdlet called "Enter-PSSession"
 

Description

The Enter-PSSession cmdlet starts an interactive session with a single remote computer. During the session, the commands that you type run on the remote computer, just as though you were typing directly on the remote computer. You can have only one interactive session at a time.
Typically, you use the ComputerName parameter to specify the name of the remote computer. However, you can also use a session that you create by using New-PSSession for the interactive session.
To end the interactive session and disconnect from the remote computer, use the Exit-PSSession cmdlet, or type "exit".

I was having trouble making this cmd work. Every time, I used to get the following error message

PS K:\> Enter-PSSession -computername 10.0.0.1 -credential USA\administrator
Enter-PSSession : Connecting to remote server failed with the following error message : The WinRM client cannot process the request. Default authentication may be used w
ith an IP address under the following conditions: the transport is HTTPS or the destination is in the TrustedHosts list, and explicit credentials are provided. Use winrm
.cmd to configure TrustedHosts. Note that computers in the TrustedHosts list might not be authenticated. For more information on how to set TrustedHosts run the followin
g command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:16
+ Enter-PSSession <<<<  -computername 10.0.0.1 -credential USA\administrator
    + CategoryInfo          : InvalidArgument: (10.0.0.1:String) [Enter-PSSession], PSRemotingTransportException
    + FullyQualifiedErrorId : CreateRemoteRunspaceFailed

After looking at help manuals and Google I found, using the following cmd "winrm quickconfig" at Powershell prompt on the destination computer will do the trick. It will enable firewall exceptions and will accept WS-Man requests to any IP on this machine.
I would like to have firewall exceptions just for few Ip Address and not "ANY IP address". Will have to do more research on this topic. Perhaps it warrents for another blogpost.

PS K:\> Enter-PSSession corp
[corp]: PS C:\Users\TOM\Documents>

All though I have not tested it throughtly, but I think there is lot of potential to use this cmd-let for day to day troubleshooting specially if you need to quickly connect to vcenter server OR some other server and want to have the link to the log files Or services that are running on the computer for example:-

To get a quick look at the services that are running for vmware

[corp]: PS C:\> Get-Service | Where-Object {$_.Displayname -like '*vm*'}

Status   Name               DisplayName
——        —-                     ———–
Running  ADAM_VMwareVCMSDS  VMwareVCMSDS
Stopped  vCOConfiguration   VMware vCenter Orchestrator Configu…
Running  vctomcat           VMware VirtualCenter Management Web…
Running  vimPBSM            VMware vSphere Profile-Driven Stora…
Running  VMTools            VMware Tools Service
Stopped  vmvss              VMware Snapshot Provider
Running  vpxd               VMware VirtualCenter Server

[corp]: PS C:\>

Leave a Reply

  • Modified logo BlogWithIntegrity.com
  • Recent Post

  • Tag Coud

    ESx Logs esxtop Licensing Logs Microsoft Cluster MSCS ODBC PowerCli Powershell Shape Data vCenter Logs vcops vcopsbadges Visio VMware vSphere

    WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.

  • Archives