header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left

[BANNER]

[BANNER]

This area of the Web site is freely editable by all registered users. When editing, expand the "Directions" item for instructions on creating and linking to new pages. Please help keep this area of the community neat and clean by adding appropriate edits and so forth.

This area of the Web site is freely editable by all registered users. When editing, expand the "Directions" item for instructions on creating and linking to new pages. Please help keep this area of the community neat and clean by adding appropriate edits and so forth.

General Stylistic Best Practices


Name: UseFourSpacesForIndentation
Short Description: Use 4 spaces for block-level indentation instead of tabs, or some other number of spaces.
Long Description:
Alignment done with the tab character tends to vary greatly between systems and editing programs. Using spaces instead of tabs helps prevent this problem, but does mean that users can't easily re-indent your script according to their indentation preferences.
Source / References:
PowerShell Team Guidance
Status: Accepted
Discussion / Open Issues:
This is generally a hotly contested issue, but one standard has to be chosen.
 
 
 
 
Name: PlaceBracesOnTheirOwnLines
Short Description: Place curly braces for large code blocks on their own lines.
Long Description:
If a script block spans multiple lines (such as the body of a looping statement,) place its enclosing braces on their own lines:
 
foreach($currentItem in $listOfItems)
{
    Write-Host "Current item is: $currentItem"
    $itemCounter++
}
 
If the entire statement is a single line that fits within a printed page (about 80 characters,) you may decide to place it entirely on one line:
 
$listOfItems | Foreach-Object { "Processing: $_" }
 
The interaction with (and transition to) .NET languages is very common with PowerShell scripters. Since this is enforced through auto-formatting default in Visual Studio, PowerShell scripting follows this guidance.
Source / References:
PowerShell Team Guidance
Status: Accepted
Discussion / Open Issues:
This is generally a hotly contested issue, but consistency with .NET code provides a significant benefit.



 |  View Topic History  |
right
footer   footer
footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
footer   footer