An operator is invoked.
Syntax:& < executable path > [< parameter list
Example:
Copy Code code as follows:
$execPath = "D:\progra~1\flashfxp\flashfxp.exe"
$execArgs = "-upload ftp://u:p@ip:21"
$execArgs = $execArgs + "-remotepath= '"/"" "
$execArgs = $execArgs + "-localpath= '" d:\123\ ' ""
& $execPath $execArgs. Split ()
This is an example of a previous call to FlashFXP to upload a file, using the & call character.
Point (.), a multi-function operator.
1, call the external PS1 script file
Copy Code code as follows:
2. Member operators
Copy Code code as follows:
$ object. property; or $ object. Method ()
3. Path operator
one point (.) represents the current directory, two dots (... ) represents a parent directory.
such as:. \test.ps1, ... \POWERSHELL\TEST.PS1, these two expressions relative to the D:\POWERSHELL\TEST.PS1, are referring to themselves.
Two o'clock (.. ), the range operator.
This is exactly the same as the two points above that indicate the parent directory, but it is not the same place to use.
"1..5" means 1 to 5, and "5..1" means 5 to 1.
When we are programming, using foreach may be a similar usage:
Copy Code code as follows:
foreach ($i in 1..5) {
Write-host $i;
}
Double colon (::), static member operator.
When PowerShell programming, it is often used. NET, and its properties and methods. For example, the Thread.Sleep () method, to be invoked in PowerShell, is invoked in the following manner.
Copy Code code as follows:
[System.threading.thread]::sleep (10000);
(-f), the format operator.
Syntax: format string-F value 1, value 2,...
Example: "{0} {1:n} {2,-10}"-F 10000,[math]::p i, "good"
$ (), child expression operator.
Evaluates the value of an expression in parentheses, somewhat like the eval () function. Returns a scalar if the value is a result. If the value is multiple, an array is returned.
Example:
Copy Code code as follows:
$i = 200;
#返回值1000
$ ($i *5);
#返回一个逻辑磁盘的对象数组
$ (Get-wmiobject Win32_LogicalDisk)
@ (), array subexpression operator.
Returns the result of one or more statements through an array. If there is only one item, the array has only one member. Such as:
Copy Code code as follows:
@ (Get-wmiobject Win32_LogicalDisk)
The comma (,) array element operator.
When this operator is used as a two-dollar operator, commas are used to create an array that lists the elements of an array. Such as:
Copy Code code as follows:
$array = "A", "B", "C", "D"
When used as a unary operator, commas are used to create an array that contains only one member. Such as:
Copy Code code as follows: