local time from a remote computer

Welcome Forums General PowerShell Q&A local time from a remote computer

This topic contains 5 replies, has 3 voices, and was last updated by

 
Participant
1 year, 11 months ago.

  • Author
    Posts
  • #57163

    Participant
    Points: 0
    Rank: Member

    Hello,

    How would I get local time a remote computer? I know about net time

    net time \\MXL6270PJF

    It says:

    Current time at \\MXL6270PJF is 11/8/2016 5:41:50 PM

    Local time (GMT-07:00) at \\MXL6270PJF is 11/8/2016 3:41:50 PM

    The command completed successfully.

    How would I get just the local time, 11/8/2016 3:41:50 PM

  • #57167

    Participant
    Points: 0
    Rank: Member
    Invoke-Command -ComputerName computername -ScriptBlock {Get-Date}
    
  • #57184

    Participant
    Points: 0
    Rank: Member

    I tried that and it says this.

    [MXL6270PJF] Connecting to remote server MXL6270PJF failed with the following error message : The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests. Consult
    the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: "winrm
    quickconfig". For more information, see the about_Remote_Troubleshooting Help topic.
    + CategoryInfo : OpenError: (MXL6270PJF:String) [], PSRemotingTransportException
    + FullyQualifiedErrorId : CannotConnect,PSSessionStateBroken

  • #57196

    Participant
    Points: 0
    Rank: Member

    I think I can use this:

    Get-WmiObject -Class win32_timezone -ComputerName MXL6271NSD

    Bias SettingID Caption
    —- ——— ——-
    -420 (UTC-07:00) Mountain Time (US & Canada)

    I just need to get the local time where the computer is located in.

  • #57217

    Participant
    Points: 0
    Rank: Member

    Hey Tony, That error you got means that powershell remoting may not be enabled on the computer you are trying to run the command on, if you go to that computer and run Enable-PSRemoting it makes security changes, firewall changes, and enables the WinRM service to use powershell remotely to it,

    I found a way to run Enable-PSRemoting remotely by using the sysinternal tool PSEXEC and running the following command with it,

    psexec \\"ComputerName or IP Address" powershell.exe "enable-psremoting -force"

    once PSRemoting is enabled on the computer, you can use Enter-PSSession and the Invoke-Command commandlets

  • #57223

    Participant
    Points: 0
    Rank: Member

    Thank you

The topic ‘local time from a remote computer’ is closed to new replies.