Search notes:

Script: touch.ps1

touch.ps1 is a very basic PowerShell script which mimicks the (IMHO) two most important use cases of the Unix touch command:
The script accepts multiple files as string array ([string[]]), that is, their names must be separated by commas:
PS C:\Users\Rene> touch foo.txt, bar,txt, baz.txt

Source code

param (
   [string[]] $fileList
)

set-strictMode -version 3

foreach ($fileName in $fileList) {
   if (test-path $fileName) {
      $file = get-item $fileName
      $file.lastAccessTime = get-date
      $file.lastWriteTime  = $file.lastAccessTime
   }
   else {
      $null = new-item $fileName
   }
}
Github repository scripts-and-utilities, path: /touch.ps1

See also

Other Scripts

Index