I recently added a touch function in PowerShell profile file
PS> notepad $profile
function touch {Set-Content -Path ($args[0]) -Value ($null)}
Saved it and ran a test for
touch myfile.txt
error returned:
touch : The term 'touch' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:1
+ touch myfile
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (touch:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
touch, unless you like the idea of accidentally destroying files. If this "function" oftouchis all you need, consider renaming itEmpty-Fileor similar... Or consider a more careful implementation, likeAdd-Content $File $null ; (dir $File).LastWriteTime = Get-Date. - Jeroen Mostertexplorer $profilein the console to verify the path and maybe addwrite-host loadedto the profile to verify it gets loaded. - marsze