Hi All,
filename giving error when used with multiple variable
$Today = Get-Date -format dd-MMM-yyyy-HH-mm-ss-tt
$serv = "myserver"
$filename = ".\"ExistingTranscript_ + $serv + _ + $Today".txt"
get-vm | out-file -path $filename
Error
At line:1 char:17
+ $filename = ".\"ExistingTranscript_ + $serv + _ + $Today".txt"
+ ~~~~~~~~~~~~~~~~~~~
Unexpected token 'ExistingTranscript_' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
Please help, how can I create a filename combining two or more variables
Please try like this
$serv = "myserver"
$filename = ".\ExistingTranscript_$serv$Today.txt"
Get-VM | Out-File -FilePath $filename
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Please try like this
$serv = "myserver"
$filename = ".\ExistingTranscript_$serv$Today.txt"
Get-VM | Out-File -FilePath $filename
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you very much, it worked