How to create an empty file with powershell, similar to "touch" on Linux, with a timestamp in the filename?
not too different from:
md5sum /etc/mtab > "$(date +"%Y_%m_%d_%I_%M_%p").log"
although that file isn't actually empty, but it does have the date incorporated into the filename itself.
Attempts on Powershell:
PS /home/nicholas/powershell/file_ops> New-Item -ItemType file foo.txt
New-Item: The file '/home/nicholas/powershell/file_ops/foo.txt' already exists.
New-Item: The file '/home/nicholas/powershell/file_ops/foo.txt' already exists.
PS /home/nicholas/powershell/file_ops> New-Item -ItemType file bar.txt
Directory: /home/nicholas/powershell/file_ops
Mode LastWriteTime Length Name
---- ------------- ------ ----
----- 12/20/2020 10:56 AM 0 bar.txt
PS /home/nicholas/powershell/file_ops> $logfile = "./"+$FN+"-LOG-AddUser_$(get-date -Format yyyymmdd_hhmmtt).txt"
ideally, to generate an arbitrary number of empty log or text files.
see also:
https://community.spiceworks.com/topic/1194231-powershell-adding-a-variable-into-a-log-filename
https://superuser.com/q/502374/977796
https://4sysops.com/archives/understanding-the-powershell-_-and-psitem-pipeline-variables/