locked
PS: retrieve install date from remote computer RRS feed

  • Question

  • How do I retrieve the Windows install date from a remote computer?
    By using

       ([WMI]'').ConvertToDateTime((Get-WmiObject Win32_OperatingSystem).InstallDate)

    I can get the info for my local machine but I can't figure out how to adapt it for use on a remote machine.

    The closest I've gotten is

       Get-WmiObject -Class Win32_OperatingSystem -Property InstallDate -ComputerName <name>

    but that gives me too much info and doesn't convert the date.
    Friday, November 13, 2009 9:55 PM

Answers

  • You were on the right track with the first command -- just add the -ComputerName parameter to the Get-WmiObject cmdlet.

    ([WMI] "").ConvertToDateTime((Get-WmiObject Win32_OperatingSystem -ComputerName computername).InstallDate)

    Bill
    • Marked as answer by Brian0975 Monday, November 16, 2009 8:21 PM
    Saturday, November 14, 2009 8:09 PM

All replies

  • You were on the right track with the first command -- just add the -ComputerName parameter to the Get-WmiObject cmdlet.

    ([WMI] "").ConvertToDateTime((Get-WmiObject Win32_OperatingSystem -ComputerName computername).InstallDate)

    Bill
    • Marked as answer by Brian0975 Monday, November 16, 2009 8:21 PM
    Saturday, November 14, 2009 8:09 PM
  • Thank you very, very much.
    It works just like I wanted it.
    Monday, November 16, 2009 8:21 PM
  • The original command was published in one of my blog articles, where I also describe other ways to get the install date:

    http://blogs.sepago.de/helge/2009/09/24/how-to-determine-the-windows-installation-date-with-and-without-powershell/

    Thursday, November 19, 2009 8:49 AM
  • Hi,

    works fine in a powershell. But if I need to call it from cmd (batch / php shell_exec) how to do?

    I tried

    powershell -command " ...." 

    powershell -command ''

    everything gives different errors. Any Trick/Tip/Idea?

    thanks 

    Marc

    powershell -command "([WMI] "").ConvertToDateTime((Get-WmiObjec
    t Win32_OperatingSystem -ComputerName hostname).InstallDate)"
    
    The string starting:
    At line:1 char:8
    + ([WMI]  <<<< ").ConvertToDateTime((Get-WmiObject Win32_OperatingSystem -Compu
    terName hostname).InstallDate)
    is missing the terminator: ".
    At line:1 char:102
    + ([WMI] ").ConvertToDateTime((Get-WmiObject Win32_OperatingSystem -ComputerNam
    e hostname).InstallDate) <<<<
        + CategoryInfo          : ParserError: ().ConvertToDate...7).InstallDate):
       String) [], ParentContainsErrorRecordException
        + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
    


    Thursday, September 12, 2013 8:30 AM

  • C:\>powershell -command "([WMI] '').ConvertToDateTime((Get-WmiObject Win32_OperatingSystem -ComputerName hostname).InstallDate)"

    Bill

    Thursday, September 12, 2013 2:31 PM
  • thanks a lot :-)

    Friday, September 13, 2013 5:10 AM