Tuesday, 8 April 2025

Create a Log File with Time Stamp using Fuction

 

function Write-Log {

    param(

        [string]$Message

    )

     $timestamp = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss")

     "$timestamp - $Message" | Out-File -FilePath C:\logs\script.log -Append

}



--------------------------------------  End -----------------------------






No comments:

Post a Comment