Touch command in powershell
The following power shell program is the similar to the Touch Command in Unix. It has the following features.
- create new file
- modify time stamp
<#Read Me: Developed By: Name:Vaneeswaran N www.vaneeswaran.com #> $Function_Exit_Status = $false #Variable to store the exit status of the function function Touch_File ($filename) { $global:Function_Exit_Status = $false if(![System.IO.File]::Exists($filename)) { echo "" > $filename $global:Function_Exit_Status = $true } else { $update = get-date try { Set-ItemProperty -Path $filename -Name LastWriteTime -Value $update $global:Function_Exit_Status = $true } catch { Log_Exception $($_.Exception.GetType().FullName) $($_.Exception.Message) $global:Function_Exit_Status = $false } } }