To jump on what Allan has already posted, you would have to escape the brackets if you want them in the file name: $LogPath\log-`[$(Get-Date -format 'yyyy-MM-dd')`].log
by antonela at 2013-03-21 01:38:11
ok, but I want to put the name 'log' as variable.
for example 1. if I have a command c:\windows\system32\powershell.exe c:\my\myfile.ps1 I want to have a log file with this name: c].log 2. if I have a command c:\windows\system32\powershell.exe c:\my\myfile2.ps1 I want to have a log file with this name: c].log
Is it possible to put in the file log the name of the argument?
if just running powershell.exe and calling the file, you can pass the values in as normal and inside the script use $args or $args to get the first and second argument respectively. You could also have a param() block as the first line of your file that will receive the arguments.