WindowsFirewallRuleset

Naming convention

This file contains an incomplete naming convention rules for symbols such as parameters and variables used accross code in this repository.

Table of Contents

Parameters

Standard Cmdlet Parameter Names and Types

Avoid using plural names for parameters ** Use Pascal Case for Parameter Names ** If a more specific name is required, use a standard parameter name, and then specify a more specific name as an alias. *** Use Standard Types for Parameters

Parameter names and aliases

* Used by most commandlets as primary parameter but should be an alias instead
ex. PSPath is an alias of both the Path and LiteralPath of most commandlets.

Unresolved

No clear conventions for the following parameters

Table of Contents

Registry keys

The following is a legend and sample table for HKEY_LOCAL_MACHINE
Starting with RootKey toward specific key value each subsequent sub key follows naming convention according to this table until key value is reached.

  1. Key type describes the type of a key beginning from top node downward toward target value
  2. Key path name describes naming convention for the [string] registry path
  3. Sub keys name describes naming convention for an [array] of sub keys
  4. Variable name describes naming convention for the [Microsoft.Win32.RegistryKey] variable name
Key type Key path name Sub keys name Variable name
Remote key RegistryHive - $RegistryHive
Targeted keys HKLM - $HKLM
Root key HKLMRootKey HKLMNames $RootKey
Sub key HKLMSubKey HKLMSubKeyNames $SubKey
Key HKLMKey HKLMKeyNames $Key
Specific key <KeyName> <KeyName>Names $<KeyName>
Key value <KeyName>Entry - $KeyNameEntry

Registry functions

  1. RegistryKey.OpenSubKey
  2. RegistryKey.GetValue
  3. RegistryKey.OpenRemoteBaseKey
  4. RegistryKey.GetSubKeyNames
  5. RegistryKey.GetValueNames

Return types

  1. The subkey requested, or null if the operation failed.
  2. The value associated with name, or null if name is not found.
  3. The requested registry key.
  4. An array of strings that contains names of the subkeys for the current key.
  5. An array of strings that contains value names for the current key.

Exceptions

ArgumentNullException

ArgumentException

ObjectDisposedException

SecurityException

IOException

UnauthorizedAccessException

Table of Contents

Variables

To name variables we use descriptive approach and pascal case similar to recommendations on how to name functions and parameters, ex:

$SearchString instead of $str

In for loops a variable which is about items in a collection should decriptively be declared so ex:

foreach ($PathEntry in $SomeCollection)
# Instead of
foreach ($i in $SomeCollection)

Custom objects

[PSCustomObject] generated by module functions must be consistent per module.

Ruleset.ProgramInfo

Minimum properties if possible in this order:

Domain = computer name
Name = program name
[version] Version = program version
Publisher = program publisher
InstallLocation = root installation directory
[PathInfo] RegistryKey = registry key that contains this data
PSTypeName = unique object type name for this module

Ruleset.UserInfo

Minimum properties if possible in this order:

Ruleset.Userinfo

Domain = computer name
User = user name
Group = group name
Principal = principal name / UPN / NetBIOS principal name
SID = security identifier of a principal
SDDL = SDDL string of a principal
[bool] LocalAccount = indicates local, roaming or MS account
PSTypeName = unique object type name for this module

Special custom objects:

Ruleset.Userinfo.Principal

Domain
Principal
SID
PSTypeName

Ruleset.Userinfo.Group

Domain
Group
SID
PSTypeName

Table of Contents