Last active
October 16, 2023 16:39
-
-
Save pbhj/99d51ce8c1a40bd443e8ea675d466ed9 to your computer and use it in GitHub Desktop.
One-liner to list a directory in powershell with added attributes, like an `ls -al` piped to a text file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://stackoverflow.com/questions/13126175/get-full-path-of-the-files-in-powershell | |
// https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/get-date | |
gci -Recurse | % { $dateTimeString = (Get-Date).ToString("yyyyMMdd-HHmmss"); $outputFileName = "AMD-listing-$dateTimeString.txt"; $_.FullName, $_.CreationTime, $_.LastWriteTime, $_.Attributes | Out-File $outputFileName -Append } | |
// semi-colon separated | |
gci -Recurse | % { $dateTimeString = (Get-Date).ToString("yyyyMMdd-HHmmss"); $outputFileName = "AMD-listing-$dateTimeString.txt"; "{0};{1};{2};{3}" -f $_.FullName, $_.CreationTime, $_.LastWriteTime, $_.Attributes | Out-File $outputFileName -Append } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment