Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Here string formatting

$
0
0

Probably a ridiculous thing to be annoyed with, but anyway...

I am trying to be good about indenting my code appropriately, as it really does aid a lot in understanding program flow. However, tabs in multi-line here strings are made part of the string, so it seems I am stuck with formatting like this:

            $LinkFolder = New-Item -Name:$Name -Path:$NethoodPath -type:Directory -ErrorAction:Stop
            # Create the ini file
            $DesktopIniContent = @"
[.ShellClassInfo]
CLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}
Flags=2
ConfirmFileOp=1"@
            $DesktopIniContent | Out-File -FilePath:"$NethoodPath\$Name\Desktop.ini"
            # Create the shortcut file
            $Link = (New-Object -ComObject:WScript.Shell -ErrorAction:Stop).Createshortcut("$NethoodPath\$Name\target.lnk")
            $Link.TargetPath = $Path
            $Link.IconLocation = "%SystemRoot%\system32\SHELL32.DLL, 85"
            $Link.Description = $Path
            $Link.WorkingDirectory = $Path
            $Link.Save()

Which looks rather shoddy. Is there a trick to get the here string indented properly without actually impacting the value? 

Gordon


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>