zirbel
zirbel

Reputation: 400

powershell - Formatting InstallationDate

Hi i want to compare the different drives. How can i format the InstallDate?

 @{"Label"=" InstallDate ";"Expression"={"{0:N}" -f ($_.InstallDate) –as [date]}}, `

There is only space in Powershell

Get-WmiObject -Class Win32_LogicalDisk |
Where-Object {$_.DriveType -ne 5} |
Sort-Object -Property Name | 
Select-Object Name, VolumeName, FileSystem, Status, Description, VolumeDirty,`
    @{"Label"="DiskSize(GB)";"Expression"={"{0:N}" -f ($_.Size/1GB) -as [float]}}, `
    @{"Label"=" InstallDate ";"Expression"={"{0:N}" -f ($_.InstallDate) –as [date]}}, `
    @{"Label"=" LastErrorCode ";"Expression"={"{0:N}" -f ($_.LastErrorCode) -as [int]}}, `
    @{"Label"="Access";"Expression"={"{0:N}" -f ($_.Access ) -as [float]}}, 
    @{"Label"="BlockSize";"Expression"={"{0:N}" -f ($_.BlockSize /1GB) -as [float]}}, `
    @{"Label"="NumberOfBlocks";"Expression"={"{0:N}" -f ($_.NumberOfBlocks /1GB) -as [float]}}, `
    @{"Label"="%Free";"Expression"={"{0:N}" -f ($_.FreeSpace/$_.Size*100) -as [float]}} |
Format-Table -AutoSize

Upvotes: 0

Views: 1701

Answers (1)

David Martin
David Martin

Reputation: 12248

To format a date you can use something like this:

"{0:yyyy-MM-dd}"

Upvotes: 1

Related Questions