Windows Vista Forums

Get time from a remote server with PowerShell v2

  1. #1


    Mehdis Guest

    Get time from a remote server with PowerShell v2

    Hi all,

    I'm looking for a way to obtain the time from a remote server. I wanted to
    use Get-Date but this doesnt seem to have any options for remote computers so
    I'm using WMI Win32_LocalTime option like this:

    $hour = Get-WmiObject Win32_LocalTime -computerName servername |
    Select-Object -Property Hour
    $minute = Get-WmiObject Win32_LocalTime -computerName servername |
    Select-Object -Property Minute
    $second = Get-WmiObject Wind32_LocalTime -computerName servername |
    Select-Object -Property Second

    However this returns values in the form of (for example):

    @{Hour=16}
    @{Minute=26}
    @{Second=30}

    Is there an easy way to obtain the time from a remote server as just a
    numeric value without the '@{Hour=' e.t.c?

    Any advice or suggestions would be much appreciated.
    Many thanks
    Mehds

      My System SpecsSystem Spec

  2. #2


    qa_warrior Guest

    Re: Get time from a remote server with PowerShell v2

    On Jan 22, 4:30*am, Mehdis <Meh...@newsgroup> wrote:

    > Hi all,
    >
    > I'm looking for a way to obtain the time from a remote server. I wanted to
    > use Get-Date but this doesnt seem to have any options for remote computers so
    > I'm using WMI Win32_LocalTime option like this:
    >
    > $hour = Get-WmiObject Win32_LocalTime -computerName servername |
    > Select-Object -Property Hour
    > $minute = Get-WmiObject Win32_LocalTime -computerName servername |
    > Select-Object -Property Minute
    > $second = Get-WmiObject Wind32_LocalTime -computerName servername |
    > Select-Object -Property Second
    >
    > However this returns values in the form of (for example):
    >
    > @{Hour=16}
    > @{Minute=26}
    > @{Second=30}
    >
    > Is there an easy way to obtain the time from a remote server as just a
    > numeric value without the '@{Hour=' e.t.c?
    >
    > Any advice or suggestions would be much appreciated.
    > Many thanks
    > Mehds
    Is PsRemoting Enabled? If So You Could Invoke-Command on the remote
    server to return Get-Date -Format HH:mm:ss

      My System SpecsSystem Spec

  3. #3


    Karl Mitschke Guest

    Re: Get time from a remote server with PowerShell v2

    Hello Mehdis,

    > Hi all,
    >
    > I'm looking for a way to obtain the time from a remote server. I
    > wanted to use Get-Date but this doesnt seem to have any options for
    > remote computers so I'm using WMI Win32_LocalTime option like this:
    >
    > $hour = Get-WmiObject Win32_LocalTime -computerName servername |
    > Select-Object -Property Hour
    > $minute = Get-WmiObject Win32_LocalTime -computerName servername |
    > Select-Object -Property Minute
    > $second = Get-WmiObject Wind32_LocalTime -computerName servername |
    > Select-Object -Property Second
    > However this returns values in the form of (for example):
    >
    > @{Hour=16}
    > @{Minute=26}
    > @{Second=30}
    > Is there an easy way to obtain the time from a remote server as just a
    > numeric value without the '@{Hour=' e.t.c?
    >
    > Any advice or suggestions would be much appreciated.
    > Many thanks
    > Mehds
    Hi;

    Try this, taken from WMI Local Time format
    :

    $dt = (Get-WmiObject-ComputerName -Query "select LocalDateTime from win32_operatingsystem").LocalDateTime
    ([wmi]'').ConvertToDateTime($dt).tostring("MM/dd/yyyy HH:mm:ss")

    You can change the format on the second line ("MM/dd/yyyy HH:mm:ss") to suit
    your needs

    Karl
    http://unlockpowershell.wordpress.com/



      My System SpecsSystem Spec

  4. #4


    Martin Zugec Guest

    Re: Get time from a remote server with PowerShell v2

    Hi Mehdis,

    you can use Get-WmiObject Win32_OperatingSystem and retrieve LocalDateTime.

    In order to convert it to regular [DateTime], use
    ([wmi]'').ConvertToDateTime() function

    Martin

    "Mehdis" <Mehdis@newsgroup> wrote in message
    news:E126F784-858F-4FC0-80D3-6E41D0499CF7@newsgroup

    > Hi all,
    >
    > I'm looking for a way to obtain the time from a remote server. I wanted to
    > use Get-Date but this doesnt seem to have any options for remote computers
    > so
    > I'm using WMI Win32_LocalTime option like this:
    >
    > $hour = Get-WmiObject Win32_LocalTime -computerName servername |
    > Select-Object -Property Hour
    > $minute = Get-WmiObject Win32_LocalTime -computerName servername |
    > Select-Object -Property Minute
    > $second = Get-WmiObject Wind32_LocalTime -computerName servername |
    > Select-Object -Property Second
    >
    > However this returns values in the form of (for example):
    >
    > @{Hour=16}
    > @{Minute=26}
    > @{Second=30}
    >
    > Is there an easy way to obtain the time from a remote server as just a
    > numeric value without the '@{Hour=' e.t.c?
    >
    > Any advice or suggestions would be much appreciated.
    > Many thanks
    > Mehds

      My System SpecsSystem Spec

  5. #5


    Mehdis Guest

    Re: Get time from a remote server with PowerShell v2

    Hi qa_warrior, thanks I didn'y know about that command. I did it as:

    Invoke-Command -ComputerName servername -ScriptBlock{Get-Date -Format
    HH:mm:ss}

    However it's a little slow on getting the result. Using WMI is a lot faster.

    Thanks again.

    "qa_warrior" wrote:

    > On Jan 22, 4:30 am, Mehdis <Meh...@newsgroup> wrote:

    > > Hi all,
    > >
    > > I'm looking for a way to obtain the time from a remote server. I wanted to
    > > use Get-Date but this doesnt seem to have any options for remote computers so
    > > I'm using WMI Win32_LocalTime option like this:
    > >
    > > $hour = Get-WmiObject Win32_LocalTime -computerName servername |
    > > Select-Object -Property Hour
    > > $minute = Get-WmiObject Win32_LocalTime -computerName servername |
    > > Select-Object -Property Minute
    > > $second = Get-WmiObject Wind32_LocalTime -computerName servername |
    > > Select-Object -Property Second
    > >
    > > However this returns values in the form of (for example):
    > >
    > > @{Hour=16}
    > > @{Minute=26}
    > > @{Second=30}
    > >
    > > Is there an easy way to obtain the time from a remote server as just a
    > > numeric value without the '@{Hour=' e.t.c?
    > >
    > > Any advice or suggestions would be much appreciated.
    > > Many thanks
    > > Mehds
    >
    > Is PsRemoting Enabled? If So You Could Invoke-Command on the remote
    > server to return Get-Date -Format HH:mm:ss
    > .
    >

      My System SpecsSystem Spec

  6. #6


    Mehdis Guest

    Re: Get time from a remote server with PowerShell v2

    I'm running on windows 7 at the moment. The last line you gave me worked
    giving the following:

    CurrentTimeZone : 0
    LastBootUpTime : 20100126114414.375199+000
    LocalDateTime : 20100126171322.660000+000



    "Karl Mitschke" wrote:

    > Hello Mehdis,
    >

    > > Hi Karl, thanks for this info and link. Unfortuantely I couldnt get it
    > > running. I kept getting:
    > >
    > > Method invocation failed because
    > > [System.Management.ManagementObject#\Win32_OperatingSystem] doesn't
    > > contain a method named 'LocalDateTime'.
    > >
    > > "Karl Mitschke" wrote:
    > >

    > >> Hello Mehdis,
    > >>
    > >>> Hi all,
    > >>>
    > >>> I'm looking for a way to obtain the time from a remote server. I
    > >>> wanted to use Get-Date but this doesnt seem to have any options for
    > >>> remote computers so I'm using WMI Win32_LocalTime option like this:
    > >>>
    > >>> $hour = Get-WmiObject Win32_LocalTime -computerName servername |
    > >>> Select-Object -Property Hour
    > >>> $minute = Get-WmiObject Win32_LocalTime -computerName servername |
    > >>> Select-Object -Property Minute
    > >>> $second = Get-WmiObject Wind32_LocalTime -computerName servername |
    > >>> Select-Object -Property Second
    > >>> However this returns values in the form of (for example):
    > >>> @{Hour=16}
    > >>> @{Minute=26}
    > >>> @{Second=30}
    > >>> Is there an easy way to obtain the time from a remote server as just
    > >>> a
    > >>> numeric value without the '@{Hour=' e.t.c?
    > >>> Any advice or suggestions would be much appreciated.
    > >>> Many thanks
    > >>> Mehds
    > >> Hi;
    > >>
    > >> Try this, taken from
    > >> WMI Local Time format :
    > >>
    > >> $dt = (Get-WmiObject-ComputerName -Query "select LocalDateTime from
    > >> win32_operatingsystem").LocalDateTime
    > >>
    > >> ([wmi]'').ConvertToDateTime($dt).tostring("MM/dd/yyyy HH:mm:ss")
    > >>
    > >> You can change the format on the second line ("MM/dd/yyyy HH:mm:ss")
    > >> to suit your needs
    > >>
    > >> Karl
    > >> http://unlockpowershell.wordpress.com/
    > >> .
    > >>
    >
    > That's strange.
    >
    > What OS?
    >
    > Try this:
    > Get-WmiObject Win32_OperatingSystem |Format-List *time*
    >
    > Karl
    > http://unlockpowershell.wordpress.com/
    >
    >
    > .
    >

      My System SpecsSystem Spec

  7. #7


    Karl Mitschke Guest

    Re: Get time from a remote server with PowerShell v2

    Hello Mehdis,

    > I'm running on windows 7 at the moment. The last line you gave me
    > worked giving the following:
    >
    > CurrentTimeZone : 0
    > LastBootUpTime : 20100126114414.375199+000
    > LocalDateTime : 20100126171322.660000+000
    > "Karl Mitschke" wrote:
    >

    >> Hello Mehdis,
    >>

    >>> Hi Karl, thanks for this info and link. Unfortuantely I couldnt get
    >>> it running. I kept getting:
    >>>
    >>> Method invocation failed because
    >>> [System.Management.ManagementObject#\Win32_OperatingSystem] doesn't
    >>> contain a method named 'LocalDateTime'.
    >>>
    >>> "Karl Mitschke" wrote:
    >>>
    >>>> Hello Mehdis,
    >>>>
    >>>>> Hi all,
    >>>>>
    >>>>> I'm looking for a way to obtain the time from a remote server. I
    >>>>> wanted to use Get-Date but this doesnt seem to have any options
    >>>>> for remote computers so I'm using WMI Win32_LocalTime option like
    >>>>> this:
    >>>>>
    >>>>> $hour = Get-WmiObject Win32_LocalTime -computerName servername |
    >>>>> Select-Object -Property Hour
    >>>>> $minute = Get-WmiObject Win32_LocalTime -computerName servername |
    >>>>> Select-Object -Property Minute
    >>>>> $second = Get-WmiObject Wind32_LocalTime -computerName servername
    >>>>> |
    >>>>> Select-Object -Property Second
    >>>>> However this returns values in the form of (for example):
    >>>>> @{Hour=16}
    >>>>> @{Minute=26}
    >>>>> @{Second=30}
    >>>>> Is there an easy way to obtain the time from a remote server as
    >>>>> just
    >>>>> a
    >>>>> numeric value without the '@{Hour=' e.t.c?
    >>>>> Any advice or suggestions would be much appreciated.
    >>>>> Many thanks
    >>>>> Mehds
    >>>> Hi;
    >>>>
    >>>> Try this, taken from
    >>>> WMI Local Time format
    >>>> :
    >>>> $dt = (Get-WmiObject-ComputerName -Query "select LocalDateTime from
    >>>> win32_operatingsystem").LocalDateTime
    >>>>
    >>>> ([wmi]'').ConvertToDateTime($dt).tostring("MM/dd/yyyy HH:mm:ss")
    >>>>
    >>>> You can change the format on the second line ("MM/dd/yyyy
    >>>> HH:mm:ss") to suit your needs
    >>>>
    >>>> Karl
    >>>> http://unlockpowershell.wordpress.com/
    >>>> .
    >> That's strange.
    >>
    >> What OS?
    >>
    >> Try this:
    >> Get-WmiObject Win32_OperatingSystem |Format-List *time*
    >> Karl
    >> http://unlockpowershell.wordpress.com/
    >> .
    >>
    OK, So we know the error you received is invalid.

    Try this (one line)

    $dt = (Get-WmiObject-ComputerName -Query "select LocalDateTime from win32_operatingsystem").LocalDateTime
    #dt

    Karl
    http://unlockpowershell.wordpress.com/



      My System SpecsSystem Spec

  8. #8


    Mehdis Guest

    Re: Get time from a remote server with PowerShell v2

    Hi Karl, thanks again for your help, that one works too, giving:

    20100127103947.257000+000

    On another forum someone suggested using exapandProperty:

    $hour = Get-WmiObject Win32_LocalTime -computerName webserver2 |
    Select-Object -expandProperty Hour

    .....and then obviously do this for minute and second too.

    Located here:
    http://powershellcommunity.org/Forum...c/Default.aspx

    I guess its another option.

    "Karl Mitschke" wrote:

    > Hello Mehdis,
    >

    > > I'm running on windows 7 at the moment. The last line you gave me
    > > worked giving the following:
    > >
    > > CurrentTimeZone : 0
    > > LastBootUpTime : 20100126114414.375199+000
    > > LocalDateTime : 20100126171322.660000+000
    > > "Karl Mitschke" wrote:
    > >

    > >> Hello Mehdis,
    > >>
    > >>> Hi Karl, thanks for this info and link. Unfortuantely I couldnt get
    > >>> it running. I kept getting:
    > >>>
    > >>> Method invocation failed because
    > >>> [System.Management.ManagementObject#\Win32_OperatingSystem] doesn't
    > >>> contain a method named 'LocalDateTime'.
    > >>>
    > >>> "Karl Mitschke" wrote:
    > >>>
    > >>>> Hello Mehdis,
    > >>>>
    > >>>>> Hi all,
    > >>>>>
    > >>>>> I'm looking for a way to obtain the time from a remote server. I
    > >>>>> wanted to use Get-Date but this doesnt seem to have any options
    > >>>>> for remote computers so I'm using WMI Win32_LocalTime option like
    > >>>>> this:
    > >>>>>
    > >>>>> $hour = Get-WmiObject Win32_LocalTime -computerName servername |
    > >>>>> Select-Object -Property Hour
    > >>>>> $minute = Get-WmiObject Win32_LocalTime -computerName servername |
    > >>>>> Select-Object -Property Minute
    > >>>>> $second = Get-WmiObject Wind32_LocalTime -computerName servername
    > >>>>> |
    > >>>>> Select-Object -Property Second
    > >>>>> However this returns values in the form of (for example):
    > >>>>> @{Hour=16}
    > >>>>> @{Minute=26}
    > >>>>> @{Second=30}
    > >>>>> Is there an easy way to obtain the time from a remote server as
    > >>>>> just
    > >>>>> a
    > >>>>> numeric value without the '@{Hour=' e.t.c?
    > >>>>> Any advice or suggestions would be much appreciated.
    > >>>>> Many thanks
    > >>>>> Mehds
    > >>>> Hi;
    > >>>>
    > >>>> Try this, taken from
    > >>>> WMI Local Time format
    > >>>> :
    > >>>> $dt = (Get-WmiObject-ComputerName -Query "select LocalDateTime from
    > >>>> win32_operatingsystem").LocalDateTime
    > >>>>
    > >>>> ([wmi]'').ConvertToDateTime($dt).tostring("MM/dd/yyyy HH:mm:ss")
    > >>>>
    > >>>> You can change the format on the second line ("MM/dd/yyyy
    > >>>> HH:mm:ss") to suit your needs
    > >>>>
    > >>>> Karl
    > >>>> http://unlockpowershell.wordpress.com/
    > >>>> .
    > >> That's strange.
    > >>
    > >> What OS?
    > >>
    > >> Try this:
    > >> Get-WmiObject Win32_OperatingSystem |Format-List *time*
    > >> Karl
    > >> http://unlockpowershell.wordpress.com/
    > >> .
    > >>
    >
    > OK, So we know the error you received is invalid.
    >
    > Try this (one line)
    >
    > $dt = (Get-WmiObject-ComputerName -Query "select LocalDateTime from win32_operatingsystem").LocalDateTime
    > #dt
    >
    > Karl
    > http://unlockpowershell.wordpress.com/
    >
    >
    > .
    >

      My System SpecsSystem Spec

  9. #9


    Karl Mitschke Guest

    Re: Get time from a remote server with PowerShell v2

    Hello Mehdis,

    > Hi Karl, thanks again for your help, that one works too, giving:
    >
    > 20100127103947.257000+000
    Then, if $dt = 20100127103947.257000+000, the second line should run fine:


    ([wmi]'').ConvertToDateTime($dt).tostring("MM/dd/yyyy HH:mm:ss")

    Karl


    > On another forum someone suggested using exapandProperty:
    >
    > $hour = Get-WmiObject Win32_LocalTime -computerName webserver2 |
    > Select-Object -expandProperty Hour
    >
    > ....and then obviously do this for minute and second too.
    >
    > Located here:
    > http://powershellcommunity.org/Forum.../4655/afv/topi
    > c/Default.aspx
    > I guess its another option.
    >
    > "Karl Mitschke" wrote:
    >

    >> Hello Mehdis,
    >>

    >>> I'm running on windows 7 at the moment. The last line you gave me
    >>> worked giving the following:
    >>>
    >>> CurrentTimeZone : 0
    >>> LastBootUpTime : 20100126114414.375199+000
    >>> LocalDateTime : 20100126171322.660000+000
    >>> "Karl Mitschke" wrote:
    >>>> Hello Mehdis,
    >>>>
    >>>>> Hi Karl, thanks for this info and link. Unfortuantely I couldnt
    >>>>> get it running. I kept getting:
    >>>>>
    >>>>> Method invocation failed because
    >>>>> [System.Management.ManagementObject#\Win32_OperatingSystem]
    >>>>> doesn't contain a method named 'LocalDateTime'.
    >>>>>
    >>>>> "Karl Mitschke" wrote:
    >>>>>
    >>>>>> Hello Mehdis,
    >>>>>>
    >>>>>>> Hi all,
    >>>>>>>
    >>>>>>> I'm looking for a way to obtain the time from a remote server. I
    >>>>>>> wanted to use Get-Date but this doesnt seem to have any options
    >>>>>>> for remote computers so I'm using WMI Win32_LocalTime option
    >>>>>>> like this:
    >>>>>>>
    >>>>>>> $hour = Get-WmiObject Win32_LocalTime -computerName servername |
    >>>>>>> Select-Object -Property Hour
    >>>>>>> $minute = Get-WmiObject Win32_LocalTime -computerName servername
    >>>>>>> |
    >>>>>>> Select-Object -Property Minute
    >>>>>>> $second = Get-WmiObject Wind32_LocalTime -computerName
    >>>>>>> servername
    >>>>>>> |
    >>>>>>> Select-Object -Property Second
    >>>>>>> However this returns values in the form of (for example):
    >>>>>>> @{Hour=16}
    >>>>>>> @{Minute=26}
    >>>>>>> @{Second=30}
    >>>>>>> Is there an easy way to obtain the time from a remote server as
    >>>>>>> just
    >>>>>>> a
    >>>>>>> numeric value without the '@{Hour=' e.t.c?
    >>>>>>> Any advice or suggestions would be much appreciated.
    >>>>>>> Many thanks
    >>>>>>> Mehds
    >>>>>> Hi;
    >>>>>>
    >>>>>> Try this, taken from
    >>>>>> http://www.vistax64.com/powershell/9...time-format.ht
    >>>>>> ml
    >>>>>> :
    >>>>>> $dt = (Get-WmiObject-ComputerName -Query "select LocalDateTime
    >>>>>> from
    >>>>>> win32_operatingsystem").LocalDateTime
    >>>>>> ([wmi]'').ConvertToDateTime($dt).tostring("MM/dd/yyyy HH:mm:ss")
    >>>>>>
    >>>>>> You can change the format on the second line ("MM/dd/yyyy
    >>>>>> HH:mm:ss") to suit your needs
    >>>>>>
    >>>>>> Karl
    >>>>>> http://unlockpowershell.wordpress.com/
    >>>>>> .
    >>>> That's strange.
    >>>>
    >>>> What OS?
    >>>>
    >>>> Try this:
    >>>> Get-WmiObject Win32_OperatingSystem |Format-List *time*
    >>>> Karl
    >>>> http://unlockpowershell.wordpress.com/
    >>>> .
    >> OK, So we know the error you received is invalid.
    >>
    >> Try this (one line)
    >>
    >> $dt = (Get-WmiObject-ComputerName -Query "select LocalDateTime from
    >> win32_operatingsystem").LocalDateTime
    >>
    >> #dt
    >>
    >> Karl
    >> http://unlockpowershell.wordpress.com/
    >> .
    >>
    Karl
    http://unlockpowershell.wordpress.com/



      My System SpecsSystem Spec

  10. #10


    Mehdis Guest

    Re: Get time from a remote server with PowerShell v2

    Yes it works now. I made the mistake of leaving them on the same line when I
    pasted into my script editor. Thank you for your help!

    "Karl Mitschke" wrote:

    > Hello Mehdis,
    >

    > > Hi Karl, thanks again for your help, that one works too, giving:
    > >
    > > 20100127103947.257000+000
    >
    > Then, if $dt = 20100127103947.257000+000, the second line should run fine:
    >
    >
    > ([wmi]'').ConvertToDateTime($dt).tostring("MM/dd/yyyy HH:mm:ss")
    >
    > Karl
    >
    >

    > > On another forum someone suggested using exapandProperty:
    > >
    > > $hour = Get-WmiObject Win32_LocalTime -computerName webserver2 |
    > > Select-Object -expandProperty Hour
    > >
    > > ....and then obviously do this for minute and second too.
    > >
    > > Located here:
    > > http://powershellcommunity.org/Forum.../4655/afv/topi
    > > c/Default.aspx
    > > I guess its another option.
    > >
    > > "Karl Mitschke" wrote:
    > >

    > >> Hello Mehdis,
    > >>
    > >>> I'm running on windows 7 at the moment. The last line you gave me
    > >>> worked giving the following:
    > >>>
    > >>> CurrentTimeZone : 0
    > >>> LastBootUpTime : 20100126114414.375199+000
    > >>> LocalDateTime : 20100126171322.660000+000
    > >>> "Karl Mitschke" wrote:
    > >>>> Hello Mehdis,
    > >>>>
    > >>>>> Hi Karl, thanks for this info and link. Unfortuantely I couldnt
    > >>>>> get it running. I kept getting:
    > >>>>>
    > >>>>> Method invocation failed because
    > >>>>> [System.Management.ManagementObject#\Win32_OperatingSystem]
    > >>>>> doesn't contain a method named 'LocalDateTime'.
    > >>>>>
    > >>>>> "Karl Mitschke" wrote:
    > >>>>>
    > >>>>>> Hello Mehdis,
    > >>>>>>
    > >>>>>>> Hi all,
    > >>>>>>>
    > >>>>>>> I'm looking for a way to obtain the time from a remote server. I
    > >>>>>>> wanted to use Get-Date but this doesnt seem to have any options
    > >>>>>>> for remote computers so I'm using WMI Win32_LocalTime option
    > >>>>>>> like this:
    > >>>>>>>
    > >>>>>>> $hour = Get-WmiObject Win32_LocalTime -computerName servername |
    > >>>>>>> Select-Object -Property Hour
    > >>>>>>> $minute = Get-WmiObject Win32_LocalTime -computerName servername
    > >>>>>>> |
    > >>>>>>> Select-Object -Property Minute
    > >>>>>>> $second = Get-WmiObject Wind32_LocalTime -computerName
    > >>>>>>> servername
    > >>>>>>> |
    > >>>>>>> Select-Object -Property Second
    > >>>>>>> However this returns values in the form of (for example):
    > >>>>>>> @{Hour=16}
    > >>>>>>> @{Minute=26}
    > >>>>>>> @{Second=30}
    > >>>>>>> Is there an easy way to obtain the time from a remote server as
    > >>>>>>> just
    > >>>>>>> a
    > >>>>>>> numeric value without the '@{Hour=' e.t.c?
    > >>>>>>> Any advice or suggestions would be much appreciated.
    > >>>>>>> Many thanks
    > >>>>>>> Mehds
    > >>>>>> Hi;
    > >>>>>>
    > >>>>>> Try this, taken from
    > >>>>>> http://www.vistax64.com/powershell/9...time-format.ht
    > >>>>>> ml
    > >>>>>> :
    > >>>>>> $dt = (Get-WmiObject-ComputerName -Query "select LocalDateTime
    > >>>>>> from
    > >>>>>> win32_operatingsystem").LocalDateTime
    > >>>>>> ([wmi]'').ConvertToDateTime($dt).tostring("MM/dd/yyyy HH:mm:ss")
    > >>>>>>
    > >>>>>> You can change the format on the second line ("MM/dd/yyyy
    > >>>>>> HH:mm:ss") to suit your needs
    > >>>>>>
    > >>>>>> Karl
    > >>>>>> http://unlockpowershell.wordpress.com/
    > >>>>>> .
    > >>>> That's strange.
    > >>>>
    > >>>> What OS?
    > >>>>
    > >>>> Try this:
    > >>>> Get-WmiObject Win32_OperatingSystem |Format-List *time*
    > >>>> Karl
    > >>>> http://unlockpowershell.wordpress.com/
    > >>>> .
    > >> OK, So we know the error you received is invalid.
    > >>
    > >> Try this (one line)
    > >>
    > >> $dt = (Get-WmiObject-ComputerName -Query "select LocalDateTime from
    > >> win32_operatingsystem").LocalDateTime
    > >>
    > >> #dt
    > >>
    > >> Karl
    > >> http://unlockpowershell.wordpress.com/
    > >> .
    > >>
    >
    > Karl
    > http://unlockpowershell.wordpress.com/
    >
    >
    > .
    >

      My System SpecsSystem Spec

Page 1 of 2 12 LastLast

Get time from a remote server with PowerShell v2
Similar Threads
Thread Forum
Re: Get time from a remote server with PowerShell v2 PowerShell
SBS2003 - main server offline - remote access to the member server SBS Server
From Virtual Server, Unable to connect to Remote SQL Server 2008 D Virtual Server
use remote to powershell to get date and time - how ? PowerShell
Powershell Startup time PowerShell