Hi,
Please help to get the filename using variable as I am unable to get.
Please help
$fold = test
$date = Get-Date -format dd-MMM-yyyy-hh-mm-tt
$reportlocation = "D:\reports\("POC_" + "$fold" + "_VM_Reporting_$date").xlsx
I am getting the below error
+ $reportlocation = "D:\reports\("POC_" + "$fold" + "_VM_Reporting_$date").xlsx
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token 'POC_" + "$fold" + "_VM_Reporting_$date").xlsx
#$fold = "Client' in expression or statement.
At D:\Jenkins\Scripts\test.ps1:180 char:67
+ ~~~~~~~~~~~~~~
The string is missing the terminator: ".
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : UnexpectedToken
No need to concatenate string swith the + here, just use variable substitution.
$date = Get-Date -Format 'dd-MMM-yyyy-hh-mm-tt'
$reportlocation = "D:\reports\POC_$($fold)_VM_Reporting_$($date).xlsx"
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
No need to concatenate string swith the + here, just use variable substitution.
$date = Get-Date -Format 'dd-MMM-yyyy-hh-mm-tt'
$reportlocation = "D:\reports\POC_$($fold)_VM_Reporting_$($date).xlsx"
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You are the champ, Thank you very much