This file contains an incomplete naming convention rules for symbols such as parameters and variables used accross code in this repository.
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
User
UserName
*Domain
ComputerName
*CN
Group
UserGroup
SID
UserSID
GroupSID
AppSID
Principal
(a unique identifiable entity for access)
Account
UserAccount
SDDL
Owner
(the name of the owner of the resource)Name
Log
(audit the actions of the cmdlet when the parameter is specified)LogName
(the name of the log file to process or use)Path
(the paths to a resource when wildcard characters are supported)
FilePath
FullName
LiteralPath
(the path to a resource when wildcard characters are not supported)
LP
Interface
(network interface name)IPAddress
(specify an IP address)
LocalAddress
RemoteAddress
URL
URI
Encoding
(ValidateSet())Application
(specify an application)
Program
InputObject
(when the cmdlet takes input from other cmdlets, ValueFromPipeline)Strict
(all errors are handled as terminating errors)Exact
(the resource term must match the resource name exactly)Privilege
(the right a cmdlet needs to perform an operation for a particular entity)Command
(specify a command string to run)Stream
(stream multiple output objects through the pipeline)Timeout
(the timeout interval (in milliseconds))Wait
(wait for user input before continuing)WaitTime
(the duration (in seconds) that the cmdlet will wait for user input)Retry
(the number of times the cmdlet will attempt an action)Count
(specify the count or specify the number of objects to be processed)Recurse
(the cmdlet recursively performs its actions on resources)From
(specify the reference object to get information from)Unique
Value
(specify a value to provide to the cmdlet)Create
(to indicate that a resource is created if one does not already exist)CaseSensitive
Binary
(the cmdlet handles binary values)Quiet
(the cmdlet suppresses user feedback during its actions)Interactive
(The cmdlet works interactively with the user when the parameter is specified)ErrorLevel
(Implement this parameter so that the user can specify the level of errors to report)Repair
(attempt to correct something from a broken state)Overwrite
(the cmdlet overwrites any existing data when the parameter is specified)Prompt
(specify a prompt for the cmdlet)State
(specify the Keyword names of states)Trusted
(trust levels are supported when the parameter is specified)TempLocation
(specify the location of temporary data that is used during operation)CertFile
(Name of a file that contains (PKCS) #12 or (DER) x.509 certificate and key)Include
(Implement this parameter so that the user can include something in an activity)All
(true indicates that all resources should be acted upon instead of a default subset of resources)Type
(the user can specify the type of resource on which to operate)Operation
(the user can specify an action that can be performed on a protected object)*
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.
No clear conventions for the following parameters
CIM
(Contact CIM server)Disabled
(Disabled user accounts)DomainName
(see: Test-UPN)AddressFamily
(ValidateSet())
IPVersion
Physical
Virtual
Connected
Hidden
Detailed
Message
Reference*
Difference*
Disable
(disable or remove setting)CertThumbprint
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.
Key type
describes the type of a key beginning from top node downward toward target valueKey path name
describes naming convention for the [string] registry pathSub keys name
describes naming convention for an [array] of sub keysVariable name
describes naming convention for the [Microsoft.Win32.RegistryKey] variable nameKey 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 |
ArgumentNullException
1
Name is null.3
MachineName is null.ArgumentException
3
hKey is invalid.ObjectDisposedException
1, 2, 4, 5
The RegistryKey is closed (closed keys cannot be accessed).1
The user does not have the permissions required to access the registry key in the specified mode.2, 5
The user does not have the permissions required to read from the registry key.3
The user does not have the proper permissions to perform this operation.4
The user does not have the permissions required to read from the key.IOException
2
The RegistryKey that contains the specified value has been marked for deletion.3
MachineName is not found.4, 5
A system error occurred, for example the current key has been deleted.2, 3, 4, 5
The user does not have the necessary registry rights.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)
[PSCustomObject]
generated by module functions must be consistent per module.
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
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