I have this code that works on my local Windows 7 machine.
(get-wmiobject win32_operatingsystem).converttodatetime((get-wmiobject win32_operatingsystem).installdate)
but both sets of code below fail. Both create the .csv file but nothing gets written to it. Why?
$PCs = Get-Content "c:\temp\tmp\machines.txt"
$OSDate = (get-wmiobject win32_operatingsystem).converttodatetime((get-wmiobject win32_operatingsystem).installdate)
Foreach ($machines in $PCs) {
$OSDate | Out-File "c:\temp\tmp\OSInstallDate.csv"
}
---------------------------------------------------------------------------------------------------
$PCs = Get-Content "c:\temp\tmp\machines.txt"
Foreach ($machines in $PCs) {
(get-wmiobject win32_operatingsystem).converttodatetime((get-wmiobject win32_operatingsystem).installdate) | Out-File "c:\temp\tmp\OSInstallDate.csv"
}