PowerShell has its own or default format of displaying the
results or the output of the cmdlets or PowerShell commands.
However, PowerShell is customisable, and the output property
can be modified.
Example below, gets the name of the file and display the
date only without the time.
PowerShell code snippet below filter a single and gets its lastwrite date.
get-childitem "C:\Users\ps_testing\Documents"
-filter IMXP2611.jpg -recurse | select Directory,
Name, @{Name="LastWriteDate";
Expression={$_.LastWriteTime.ToString("yyyy-MM-dd")}} | ft
-wrap
This can be modified using wildchars like "*", which filters all "jpg" regardless of filename.
get-childitem "C:\Users\ps_testing\Documents" -filter *.jpg -recurse | select Directory, Name, @{Name="LastWriteDate";
Expression={$_.LastWriteTime.ToString("yyyy-MM-dd")}} | ft -wrap
LastWriteDate == is a custom label for the output
yyyy-MM-dd == is a custom format that display only the date
in year, month and day format
@{Name="LastWriteDate"; Expression={$_.LastWriteTime.ToString("yyyy-MM-dd")}}
== is where the customisation takes place
Sample Output:
Directory Name LastWriteDate
--------- ---- -------------
C:\Users\ ps_testing \Documents IMXP2611.jpg 2019-09-22
Well, that is just a basic example. Play around with the “expression”
property for other possible options.
================================
Free Android Apps:
Click links below to find out more:
Excel Keyboard guide:
Heaven's Dew Fall Prayer app for Android :
Catholic Rosary Guide for Android:
Comments
Post a Comment