Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions reference/3.0/Microsoft.PowerShell.Core/About/about_Methods.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
---
---
ms.date: 06/09/2017
schema: 2.0.0
locale: en-us
keywords: powershell,cmdlet
title: about_Methods
---

# About methods

## SHORT DESCRIPTION
Expand All @@ -30,7 +29,7 @@ To get the methods of any object, use the `Get-Member` cmdlet. Use its
the methods of process objects.

```powershell
PS C:\> Get-Process | Get-Member -MemberType Method
PS> Get-Process | Get-Member -MemberType Method
```

```output
Expand Down Expand Up @@ -68,8 +67,8 @@ takes a delimiter character argument that tells the method where to split the
string.

```powershell
PS C:\> $a = "Try-Catch-Finally"
PS C:\> $a.Split("-")
PS> $a = "Try-Catch-Finally"
PS> $a.Split("-")
Try
Catch
Finally
Expand Down Expand Up @@ -155,15 +154,15 @@ command uses the `Get-Process` command to get all three instance of the Notepad
process and save them in the \$p variable.

```powershell
PS C:\> Notepad; Notepad; Notepad
PS C:\> $p = Get-Process Notepad
PS> Notepad; Notepad; Notepad
PS> $p = Get-Process Notepad
```

The third command uses the Count property of all collections to verify that
there are three processes in the \$p variable.

```powershell
PS C:\> $p.Count
PS> $p.Count
3
```

Expand All @@ -174,18 +173,18 @@ This command works even though a collection of processes does not have a `Kill`
method.

```
PS C:\> $p.Kill()
PS> $p.Kill()
```

The fifth command uses the Get-Process command to confirm that the `Kill`
command worked.

```powershell
PS C:\> Get-Process Notepad
PS> Get-Process Notepad
Get-Process : Cannot find a process with the name "notepad". Verify the proc
ess name and call the cmdlet again.
At line:1 char:12
+ get-process <<<< notepad
+ Get-Process <<<< notepad
+ CategoryInfo : ObjectNotFound: (notepad:String) [Get-Process]
, ProcessCommandException
+ FullyQualifiedErrorId : NoProcessFoundForGivenName,Microsoft.PowerShel
Expand All @@ -196,7 +195,7 @@ To perform the same task on PowerShell 2.0, use the `Foreach-Object` cmdlet to
run the method on each object in the collection.

```powershell
PS C:\> $p | Foreach-Object {$_.Kill()}
PS> $p | ForEach-Object {$_.Kill()}
```

## SEE ALSO
Expand Down
26 changes: 13 additions & 13 deletions reference/3.0/Microsoft.PowerShell.Core/About/about_Modules.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
---
---
ms.date: 11/29/2017
schema: 2.0.0
locale: en-us
keywords: powershell,cmdlet
title: about_Modules
---

# About Modules

## Short Description
Expand Down Expand Up @@ -43,6 +42,7 @@ gets all commands in all installed modules, even if they are not yet in the
session, so you can find a command and use it without importing.

Any of the following commands will import a module into your session.

### Run the Command

```powershell
Expand Down Expand Up @@ -486,17 +486,17 @@ NOTE: Remote sessions, including sessions that are started by using the
commands are packaged in snap-ins.

The following modules (or snap-ins) are installed with PowerShell.
* Microsoft.PowerShell.Core
* Microsoft.PowerShell.Diagnostics
* Microsoft.PowerShell.Host
* Microsoft.PowerShell.Management
* Microsoft.PowerShell.Security
* Microsoft.PowerShell.Utility
* Microsoft.WSMan.Management
* PSScheduledJob
* PSWorkflow
* PSWorkflowUtility
* ISE
- Microsoft.PowerShell.Core
- Microsoft.PowerShell.Diagnostics
- Microsoft.PowerShell.Host
- Microsoft.PowerShell.Management
- Microsoft.PowerShell.Security
- Microsoft.PowerShell.Utility
- Microsoft.WSMan.Management
- PSScheduledJob
- PSWorkflow
- PSWorkflowUtility
- ISE

## Logging Module Events

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
---
---
ms.date: 11/30/2017
schema: 2.0.0
locale: en-us
keywords: powershell,cmdlet
title: about_Object_Creation
---

# About Object Creation

## SHORT DESCRIPTION
Expand Down Expand Up @@ -43,8 +42,8 @@ ProgID of a COM object.
For example, the following command creates a Version object.

```powershell
PS C:\> $v = New-Object -TypeName System.Version -ArgumentList 2.0.0.1
PS C:\> $v
PS> $v = New-Object -TypeName System.Version -ArgumentList 2.0.0.1
PS> $v
```

```Output
Expand All @@ -54,7 +53,7 @@ Major Minor Build Revision
```

```powershell
PS C:\> $v | Get-Member
PS> $v | Get-Member

TypeName: System.Version
```
Expand Down Expand Up @@ -118,7 +117,7 @@ The output of this function is a collection of custom objects formatted as a
table by default.

```powershell
PS C:\> Test-Object
PS> Test-Object

ModuleName UICulture Version
--------- --------- -------
Expand All @@ -130,7 +129,7 @@ Users can manage the properties of the custom objects just as they do with
standard objects.

```powershell
PS C:\> (Test-Object).ModuleName
PS> (Test-Object).ModuleName
PSScheduledJob
PSWorkflow
```
Expand Down Expand Up @@ -202,8 +201,8 @@ AssetID, Name, OS, Department
```

```powershell
PS C:\> $a = Import-Csv Servers.csv
PS C:\> $a
PS> $a = Import-Csv Servers.csv
PS> $a

AssetID Name OS Department
------- ---- -- ----------
Expand All @@ -215,7 +214,7 @@ AssetID Name OS Department
Use the Get-Member cmdlet to confirm the object type.

```powershell
PS C:\> $a | Get-Member
PS> $a | Get-Member
```

```Output
Expand All @@ -236,7 +235,7 @@ OS NoteProperty System.String OS=Windows Server 2012
You can use the custom objects just as you would standard objects.

```powershell
PS C:\> $a | where {$_.OS -eq "Windows 8"}
PS> $a | Where-Object {$_.OS -eq "Windows 8"}
```

```output
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
---
---
ms.date: 11/30/2017
schema: 2.0.0
locale: en-us
keywords: powershell,cmdlet
title: about_Objects
---

# About Objects

## Short Description
Expand Down Expand Up @@ -49,7 +48,7 @@ The following example demonstrates how objects are passed from one
command to the next:

```powershell
Get-ChildItem C: | where { $_.PsIsContainer -eq $false } | Format-List
Get-ChildItem C: | Where-Object { $_.PsIsContainer -eq $false } | Format-List
```

The first command `Get-ChildItem C:` returns a file or directory object
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
---
---
ms.date: 11/30/2017
schema: 2.0.0
locale: en-us
keywords: powershell,cmdlet
title: about_Operator_Precedence
---

# About Operator Precedence

## SHORT DESCRIPTION
Expand Down Expand Up @@ -91,23 +90,24 @@ using parentheses to force PowerShell to evaluate the enclosed part of
the expression first.

```powershell
C:\PS> 2 + 3 * 4
PS> 2 + 3 * 4
14

C:\PS> (2 + 3) * 4
PS> (2 + 3) * 4
20
```

The following example gets the read-only text files from the local directory
and saves them in the `$read_only` variable.

```powershell
$read_only = get-childitem *.txt | where-object {$_.isReadOnly}
$read_only = Get-ChildItem *.txt | Where-Object {$_.isReadOnly}
```

It is equivalent to the following example.

```powershell
$read_only = ( get-childitem *.txt | where-object {$_.isReadOnly} )
$read_only = ( Get-ChildItem *.txt | Where-Object {$_.isReadOnly} )
```

Because the pipeline operator (|) has a higher precedence than the assignment
Expand All @@ -124,7 +124,7 @@ which is the first string. Finally, it casts the selected object as a string.
In this case, the cast has no effect.

```powershell
C:\PS> [string]@('Windows','PowerShell','2.0')[0]
PS> [string]@('Windows','PowerShell','2.0')[0]
Windows
```

Expand All @@ -134,7 +134,7 @@ before the index selection. As a result, the entire array is cast as a
array, which is the first character.

```powershell
C:\PS> ([string]@('Windows','PowerShell','2.0'))[0]
PS> ([string]@('Windows','PowerShell','2.0'))[0]
W
```

Expand All @@ -143,21 +143,21 @@ precedence than the -and (logical AND) operator, the result of the expression
is FALSE.

```powershell
C:\PS> 2 -gt 4 -and 1
PS> 2 -gt 4 -and 1
False
```

It is equivalent to the following expression.

```powershell
C:\PS> (2 -gt 4) -and 1
PS> (2 -gt 4) -and 1
False
```

If the -and operator had higher precedence, the answer would be TRUE.

```powershell
C:\PS> 2 -gt (4 -and 1)
PS> 2 -gt (4 -and 1)
True
```

Expand Down
17 changes: 8 additions & 9 deletions reference/3.0/Microsoft.PowerShell.Core/About/about_Operators.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
---
---
ms.date: 06/09/2017
schema: 2.0.0
locale: en-us
keywords: powershell,cmdlet
title: about_Operators
---

# About Operators

## SHORT DESCRIPTION
Expand Down Expand Up @@ -113,7 +112,7 @@ Returns the result of one or more statements as an array. If there is only
one item, the array has only one member.

```powershell
@(Get-WMIObject win32_logicalDisk)
@(Get-WmiObject win32_logicalDisk)
```

`&` Call operator
Expand Down Expand Up @@ -209,7 +208,7 @@ $a[-1]
```

```powershell
(get-hotfix | sort installedOn)[-1]
(Get-HotFix | Sort-Object installedOn)[-1]
```

```powershell
Expand All @@ -235,8 +234,8 @@ that follows it. When the output includes more than one object (a
"collection"), the pipeline operator sends the objects one at a time.

```powershell
get-process | get-member
get-pssnapin | where {$_.vendor -ne "Microsoft"}
Get-Process | Get-Member
Get-PSSnapin | Where-Object {$_.vendor -ne "Microsoft"}
```

`.` Property dereference operator
Expand All @@ -245,7 +244,7 @@ Accesses the properties and methods of an object.

```powershell
$myProcess.peakWorkingSet
(get-process PowerShell).kill()
(Get-Process PowerShell).kill()
```

`..` Range operator
Expand All @@ -256,7 +255,7 @@ lower boundary.
```powershell
1..10
10..1
foreach ($a in 1..$max) {write-host $a}
foreach ($a in 1..$max) {Write-Host $a}
```

`::` Static member operator
Expand All @@ -276,7 +275,7 @@ a scalar. For multiple results, returns an array.

```powershell
$($x * 23)
$(Get-WMIObject win32_Directory)
$(Get-WmiObject win32_Directory)
```

## SEE ALSO
Expand Down
Loading