MSDN script not quite right?

Hello folks!

I was exploring the compliance server and came across this nugget http://blogs.technet.com/b/privatecloud/archive/2014/08/08/desired-state-configuration-dsc-nodes-deployment-and-conformance-reporting-series-part-3-working-with-the-conformance-endpoint.aspx

Full script in question:

Function Get-DscConformanceReport {
    param (
        $Uri = 'http://localhost:9080/PSDSCComplianceServer.svc/Status'
    )
    $response = Invoke-RestMethod -Uri $uri -UseDefaultCredentials -Method Get -Headers @{Accept="application/json"}
    $NodeStatus = $response.value | 
                  Select @{Name='TargetName';Expression={[System.Net.Dns]::GetHostByAddress($_.TargetName).HostName}}, ConfigurationId, NodeCompliant, @{Name='Status';Expression={$statusCode[$_.StatusCode]}}
    
    #Construct HTML 
    $HtmlBody = "'
    $TableContent="TargetNameConfigurationIdNodeComplaintStatus'
    foreach ($Node in $NodeStatus) {
        if (-not ([bool]$Node.NodeCompliant)) {
            $TableContent += "'
        } else {
            $TableContent += "'
        }
        $TableContent += "$($Node.TargetName)$($Node.ConfigurationId)$($Node.NodeCompliant)$($Node.Status)"        
    } 
    $TableContent += ""
    $HtmlBody += $TableContent + ""

    #Generate HTML file
    $HtmlBody | Out-File "$env:Temp\DscReport.HTML" -Force
    Start-Process -FilePath iexplore.exe -ArgumentList "$env:Temp\DscReport.HTML"
}

I bring the script about modifying the HTML to my ISE and it highlights this section as being erroneous:

    #Construct HTML 
    $HtmlBody = "'
    $TableContent="TargetNameConfigurationIdNodeComplaintStatus'
    foreach ($Node in $NodeStatus) {
        if (-not ([bool]$Node.NodeCompliant)) {
            $TableContent += "'
        } else {
            $TableContent += "'
        }

Running the above generates this powershell error:

Function Get-DscConformanceReport {
    param (
        $Uri = 'http://localhost:9080/PSDSCComplianceServer.svc/Status'
    )
    $response = Invoke-RestMethod -Uri $uri -UseDefaultCredentials -Method Get -Headers @{Accept="application/json"}
    $NodeStatus = $response.value | 
                  Select @{Name='TargetName';Expression={[System.Net.Dns]::GetHostByAddress($_.TargetName).HostName}}, ConfigurationId, NodeCompliant, @{Name='Status';Expression={$statusCode[$_.StatusCode]}}
    
    #Construct HTML 
    $HtmlBody = "'
    $TableContent="TargetNameConfigurationIdNodeComplaintStatus'
    foreach ($Node in $NodeStatus) {
        if (-not ([bool]$Node.NodeCompliant)) {
            $TableContent += "'
        } else {
            $TableContent += "'
        }
        $TableContent += "$($Node.TargetName)$($Node.ConfigurationId)$($Node.NodeCompliant)$($Node.Status)"        
    } 
    $TableContent += ""
    $HtmlBody += $TableContent + ""

    #Generate HTML file
    $HtmlBody | Out-File "$env:Temp\DscReport.HTML" -Force
    Start-Process -FilePath iexplore.exe -ArgumentList "$env:Temp\DscReport.HTML"
}
At line:11 char:20
+     $TableContent="Target ...
+                    ~
The '<' operator is reserved for future use.
At line:11 char:31
+     $TableContent="Target ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token 'style='color: #fff; background: black;'>TargetNameConfigurationIdNodeComplaintStatus'
    foreach ($Node in $NodeStatus) {
        if (-not ([bool]$Node.NodeCompliant)) {
            $TableContent += "<tr style='color:' in expression or statement.
At line:25 char:81
+ ... \DscReport.HTML"
+                    ~
The string is missing the terminator: ".
At line:18 char:27
+         $TableContent += "$($Node.TargetName)$($Node.ConfigurationI ...
+                           ~
The '<' operator is reserved for future use.
At line:15 char:16
+         } else {
+                ~
Missing closing '}' in statement block.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : RedirectionNotSupported 

I tried messing around with it but couldn't find the culprit. Any clues?

First, you might try asking the original poster of the content. Also, these formatting problems can be difficult to catch here in the forums. This is definitely a typo, I think.

    $HtmlBody = "'
    $TableContent="TargetNameConfigurationIdNodeComplaintStatus'

In both cases, it appears to me that a double quote is opening the string literal, but a single quote is closing it. That’s not legal. It’s possible the formatting was off when you copied the script from MSDN, but you’ll need to run through and check it all.