OS Install Date Output to Text File

Hi Everyone, I'm fairly inexperienced with batch scripting, so I need some help with a task. I need to issue this command:

systeminfo | find /i "install date" 

I need to collect the OS install date for machines, wanted to run this as a batch file with "pause" at the end, but it won't run and stay open to display the information. I assumed I could output the info the a text file, but because it won't run correctly via a batch script, i can't get it to output either.

Any ideas on how I can do this? I need a rapid way of finding the OS install dates that can be generically copied from multiple PCs. 

Thanks.


March 20th, 2015 11:03am

Hi Mike,

Why batch? This is quick and easy with PowerShell:

$pcs = 'PC1','PC2'

$pcs | ForEach {

    If (Test-Connection -ComputerName $_ -Count 1 -Quiet) {

        Get-WmiObject Win32_OperatingSystem -ComputerName $_ |
            Select CSName,@{N='InstallDate';E={[System.Management.ManagementDateTimeConverter]::ToDateTime($_.InstallDate)}}

    }

} | Export-Csv .\OSInstallDates.csv -NoTypeInformation

Free Windows Admin Tool Kit Click here and download it now
March 20th, 2015 11:11am

I only chose batch because I knew some commands, PowerShell I've never used.

Where is the file exporting to, I don't see it in the same place as the powershell file.


March 20th, 2015 11:30am

I only chose batch because I knew some commands, PowerShell I've never used.

Where is the file exporting to, I don't see it in the same place as the powershell file.

It should be the the current directory. That's what the '.\' in the path specifies.

Free Windows Admin Tool Kit Click here and download it now
March 20th, 2015 11:41am

Cheers, you're very welcome.

PowerShell will make your life much easier, I promise. Here's a good starting point:

http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx

March 20th, 2015 11:48am

So I was able to get the PowerShell command to run, but nothing was shown in the csv file after it was exported.
Free Windows Admin Tool Kit Click here and download it now
March 20th, 2015 12:42pm

Then the machines you put in the $pcs array aren't o

March 20th, 2015 12:49pm

I only chose batch because I knew some commands, PowerShell I've never used.

Where is the file exporting to, I don't see it in the same place as the powershell file.


Free Windows Admin Tool Kit Click here and download it now
March 20th, 2015 3:26pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics