Skip to content

Instantly share code, notes, and snippets.

@pbhj
Last active October 16, 2023 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbhj/99d51ce8c1a40bd443e8ea675d466ed9 to your computer and use it in GitHub Desktop.
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
// 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