You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am not sure if this has been reported before, but multi-line strings do not seem to store correctly within powershell scripts when they are not left aligned to line space 0. If the closing '"@' is not in space 0, all code following this end marker is highlighted as a continuation of the comment block.
E.g. the following code displays only the required multi-line string as a intended.
$DefaultConfigFile = @"
@{
# Specify the desired logs directory, by default this is the current working directory in a subfolder named logs
LogFileDirectory = '.\Logs'
# Specify the desired log file prefix, the default prefix is the first token of the last line of input
LogFilePrefix = 'ChangeMe'
# Specify the log file extension, this can be safely left at .txt, please include the leading full stop
LogFileExtension = '.txt'
# Specify the log datestamp format, this string will be passed to Get-Date -Format
LogFileDateFormat = 'yyyyMMddHHmm'
# Specify the amount of days that the logs will be retained for
LogFileRetentionPeriod = 10
}
"@
Add-Content -Path ($pwd.Path + '\' + 'Out-Log.conf.psd1') -Value $DefaultConfigFile
Whereas the following code shows the rest of the script as a singular string, causing code warnings (Red squiggly lines)
$DefaultConfigFile = @"
@{
# Specify the desired logs directory, by default this is the current working directory in a subfolder named logs
LogFileDirectory = '.\Logs'
# Specify the desired log file prefix, the default prefix is the first token of the last line of input
LogFilePrefix = 'ChangeMe'
# Specify the log file extension, this can be safely left at .txt, please include the leading full stop
LogFileExtension = '.txt'
# Specify the log datestamp format, this string will be passed to Get-Date -Format
LogFileDateFormat = 'yyyyMMddHHmm'
# Specify the amount of days that the logs will be retained for
LogFileRetentionPeriod = 10
}
"@
Add-Content -Path ($pwd.Path + '\' + 'Out-Log.conf.psd1') -Value $DefaultConfigFile
Sorry about the rough formatting, I am currently out on the road so I am not able to make it look "pretty" or upload logs.
Cheers,
SubThr33
Attached Logs
The text was updated successfully, but these errors were encountered:
The multi-line strings you refer to are called here strings and the syntax requires that the closing quotation has to be the first character on the line. See the help topic man about_quoting_rules. Your second example is invalid syntax. The red squiggles you see are telling you that.
System Details
$PSVersionTable
:Issue Description
Hi, I am not sure if this has been reported before, but multi-line strings do not seem to store correctly within powershell scripts when they are not left aligned to line space 0. If the closing '"@' is not in space 0, all code following this end marker is highlighted as a continuation of the comment block.
E.g. the following code displays only the required multi-line string as a intended.
Whereas the following code shows the rest of the script as a singular string, causing code warnings (Red squiggly lines)
Sorry about the rough formatting, I am currently out on the road so I am not able to make it look "pretty" or upload logs.
Cheers,
SubThr33
Attached Logs
The text was updated successfully, but these errors were encountered: