I have the below code and currently it loads all the information on screen. I want it to log to a log file on D:\\Apps\\Logs.
The log file needs to have the name of
function WriteLog { Param ([string]$LogString) $LogFile = "C:\$(gc env:computername).log" $DateTime = "[{0:MM/dd/yy} {0:HH:mm:ss}]" -f (Get-Date) $LogMessage = "$Datetime $LogString" Add-content $LogFile -value $LogMessage } WriteLog "This is my log message"