The naming of function parameters in PowerShell _powershell

Source: Internet
Author: User

PowerShell the parameters of a custom function do not have a specific naming rule, then what can be done to make the name of the argument more scientific and sustainable.

What should we do to name the parameters of the function? Is there a list available for reference? Of course Microsoft didn't give it up. But we can come up with a list. Microsoft has brought in a large number of cmdlet, what are the rules of the parameters used by these cmdlet? We use the following order to count.

Copy Code code as follows:

Get-command-commandtype Cmdlet |
Foreach-object {$_. Parameters} |
Foreach-object {$_. Keys} |
group-object-noelement |
Sort-object Count, name-descending |
Select-object-skip 11 |
Where-object {$_. COUNT-GT 1}

The purpose of this code is to make a statistic of the names of the parameters used by all the cmdlet, to see which names are used in more arguments, and then to make a list in order of how many to less. The results of this small series are as follows:
Copy Code code as follows:

Count Name
----- ----
Force
Inputobject
Credential
Path
PassThru
Literalpath
Km usetransaction
Exclude
Include
ComputerName
Filter
Num Id
Scope
Property
Instanceid
Value
Authentication
Throttlelimit
Description
ArgumentList
Session
Ten Encoding
9 Sourceidentifier
8 wait
8 Namespace
8 DisplayName
8 Certificatethumbprint
8 Asjob
7 UseSSL
7 Stream
7 State
7 Port
7 Noclobber
7 Impersonation
7 FilePath
6 TypeName
6 Timeout
6 sessionoption
6 Option
6 Module
6 message
6 LogName
6 Job
6 Connectionuri
6 ConfigurationName
6 Command
6 Class
6 ApplicationName
6 allowredirection
5 View
5 Variable
5 Source
5 recurse
5 Psprovider
5 Delimiter
4 useDefaultCredentials
4 useculture
4 UICulture
4 Stackname
4 ShowError
4 NewName
4 MessageData
4 Locale
4 GroupBy
4 Expand
4 enableallprivileges
4 DisplayError
4 destination
4 Depth
4 Culture
4 Count
4 Certificate
4 Category
4 casesensitive
4 body
4 Authority
4 Append
4 Action
3 Width
3 Uri
3 supportevent
3 Server
3 SECURITYDESCRIPTORSDDL
3 Scriptblock
3 restart
3 psversion
3 proxycredential
3 Outputbufferingmode
3 notypeinformation
3 Noservicerestart
3 Newest
3 Modulestoimport
3 MemberType
3 Maxtriggercount
3 maximumredirection
3 localcredential
3 List
3 Function
3 Forward
3 enablenetworkaccess
3 CommandType
3 Cmdlet
3 Breakpoint
3 asstring
3 AssemblyName
3 AS
2 websession
2 Visibility
2 Verb
2 usesharedprocess
2 useragent
2 unjoindomaincredential
2 Unique
2 typestoprocess
2 Typedata
2 Type
2 transportoption
2 transferencoding
2 TotalCount
2 Title
2 timeoutsec
2 threadoptions
2 Threadapartmentstate
2 SubscriptionId
2 Strict
2 Status
2 Startuptype
2 Startupscript
2 Skipnetworkprofilecheck
2 Skip
2 Showsecuritydescriptorui
2 sessionvariable
2 sessiontypeoption
2 Sessiontype
2 SecondValue
2 Seconds
2 scriptstoprocess
2 Script
2 runascredential
2 Restorepoint
2 Resolve
2 Quiet
2 Query
2 pssession
2 Pshost
2 proxyusedefaultcredent ...
2 Proxy
2 processorarchitecture
2 Prependpath
2 Prefix
2 powershellversion
2 outfile
2 off
2 Notmatch
2 Moduleinfo
2 Minimum
2 method
2 MemberName
2 maximumreceivedobjects ...
2 Maximumreceiveddatasiz ...
2 Maximum
2 Literalname
2 listeneroption
2 Line
2 JobName
2 InFile
2 Index
2 idletimeoutsec
2 Headers
2 Header
2 Guid
2 Formattypename
2 formatstoprocess
2 the
2 Expression
2 EventIdentifier
2 EntryType
2 End
2 Drive
2 Displayhint
2 disablenamechecking
2 disablekeepalive
2 Delay
2 Debugger
2 Date
2 Copyright
2 ContentType
2 Configurationtypename
2 CompanyName
2 CommandName
2 Column
2 cimsession
2 Cimresourceuri
2 Cimnamespace
2 CanonicalName
2 before
2 AutoSize
2 Author
2 Ascustomobject
2 ApplicationBase
2 Appendpath
2 Allowclobber
2 All
2 Alias
2 after
2 AccessMode

Well, see this list, I believe you have a certain understanding of how to set a parameter name. Refer to the name on the list, or use the name on the list to make your cmdlet easier to understand!

About the parameters of the PowerShell function should be named, this article on the introduction of so many, I hope to help you, thank you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.