I am trying to create a log filename for today date time using powershell command
$date = Get-Date
$log = "D:\NewFolder\Logs\FixService$date.log"
"Write this text to log" >> $log
I am getting error as shown below , How to do this?
out-file : The given path's format is not supported. At D:\NewFolder\somefile.ps1:5 char:1 + "Write this text to log" >> $log + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OpenError: (:) [Out-File], NotSupportedException + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand
But this works without date in log file name
$date = Get-Date
$log = "D:\Crowdstrike\Logs\FixService.log"
"Write this to log" >> $log
What I am doing wrong?