Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Opinions please - line numbers in codeblocks

$
0
0

Hi all,

I was recently playing around with our 'Insert Code Block' functionality and came across a method for automatically adding in line numbers. These line numbers do not get copied when copy/pasting, so they shouldn't stop people from easily moving code in and out of the forums. Adding the line numbers in isn't difficult (editing the html and adding one word to the pre tag class ['linenums']), but I'm not even sure if it's worth the few seconds it takes to do it.

There's also a caveat when using this. If you ever edit your post again without removing linenums from the pre tag class, you'll keep adding additional line numbers and everything looks completely strange. You can see all of my random testing in the sandbox here.

So, what's everyone's opinion on this? Would this be helpful to the folks who come here looking for help or is this just a waste of time?

Here's an example of a 50 line script that I posted yesterday:

$out = @()

Get-ADGroupMember 'Domain Admins' | ForEach {

    $userDetails = Get-ADUser -Identity $_.SamAccountName

    $props = @{
        SecurityGroup = 'Domain Admins'
        Username = $userDetails.SamAccountName
        FirstName = $userDetails.GivenName
        LastName = $userDetails.SurName
    }

    $out += New-Object PsObject -Property $props

}

Get-ADGroupMember 'Enterprise Admins' | ForEach {

    $userDetails = Get-ADUser -Identity $_.SamAccountName

    $props = @{
        SecurityGroup = 'Enterprise Admins'
        Username = $userDetails.SamAccountName
        FirstName = $userDetails.GivenName
        LastName = $userDetails.SurName
    }

    $out += New-Object PsObject -Property $props

}

Get-ADGroupMember 'Schema Admins' | ForEach {

    $userDetails = Get-ADUser -Identity $_.SamAccountName

    $props = @{
        SecurityGroup = 'Schema Admins'
        Username = $userDetails.SamAccountName
        FirstName = $userDetails.GivenName
        LastName = $userDetails.SurName
    }

    $out += New-Object PsObject -Property $props

}

$body = $out | Out-String

Send-MailMessage -To to@domain.com -From from@domain.com -Subject 'Group Report' -Body $body -SmtpServer smtp.domain.com

Note: I have not edited (and now can't) this post, so the tags should show up properly in the source or XML views.


Don't retire TechNet! - (Don't give up yet - 12,700+ strong and growing)


Viewing all articles
Browse latest Browse all 15028

Trending Articles



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