local time from a remote computer

Tagged: 

This topic contains 5 replies, has 3 voices, and was last updated by Profile photo of Tony Antony Tony Antony 3 weeks, 2 days ago.

  • Author
    Posts
  • #57163
    Profile photo of Tony Antony
    Tony Antony
    Participant

    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
    Profile photo of random commandline
    random commandline
    Participant
    Invoke-Command -ComputerName computername -ScriptBlock {Get-Date}
    
  • #57184
    Profile photo of Tony Antony
    Tony Antony
    Participant

    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
    Profile photo of Tony Antony
    Tony Antony
    Participant

    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
    Profile photo of My Name
    My Name
    Participant

    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
    Profile photo of Tony Antony
    Tony Antony
    Participant

    Thank you

You must be logged in to reply to this topic.