Learning about methods
To find definitions of the methods of an object, go to help topic for the
object type and look for its methods page. For example, the following page
describes the methods of process objects System.Diagnostics.Process.
To determine the arguments of a method, review the method definition, which
is like the syntax diagram of a PowerShell cmdlet.
A method definition might have one or more method signatures, which are
like the parameter sets of PowerShell cmdlets. The signatures show all of
the valid formats of commands to invoke the method.
For example, the CopyTo method of the FileInfo class contains the following
two method signatures:
CopyTo(String destFileName)
CopyTo(String destFileName, Boolean overwrite)
The first method signature takes the destination file name (and a path).
The following example uses the first CopyTo method to copy the Final.txt
file to the C:\Bin directory.
(Get-ChildItem c:\final.txt).CopyTo("c:\bin\final.txt")
[!NOTE] Unlike PowerShell's _argument_ mode, object methods execute in
_expression_ mode, which is a pass-through to the .NET framework that
PowerShell is built on. In _expression_ mode BAREWORD arguments (unquoted
strings) are not allowed. You can see this difference when using a the
path as a parameter, versus the path as an argument. You can read more
about parsing modes in about_Parsing
The second method signature takes a destination file name and a Boolean
value that determines whether the destination file should be overwritten,
if it already exists.