function New-LogFile { param($LogPath) ``` if (!(Test-Path $LogPath)) { New-Item -ItemType Directory -Path $LogPath | Out-Null } return Join-Path $LogPath ("Shutdown_{0}.log" -f (Get-Date -Format "yyyy-MM-dd_HH-mm-ss")) ``` } function Write-Log { param( [string]$Message, [string]$Level = "INFO" ) ``` $line = "[{0}] {1}" -f $Level, $Message Write-Host $line ``` }