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
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
---
---
ms.date: 11/28/2017
schema: 2.0.0
locale: en-us
keywords: powershell,cmdlet
title: about_Functions_Advanced_Parameters
---

# About Functions Advanced Parameters

# SHORT DESCRIPTION
Expand Down Expand Up @@ -514,7 +513,7 @@ greater than or equal to the current date.
Param
(
[parameter()]
[ValidateScript({$_ -ge (get-date)})]
[ValidateScript({$_ -ge (Get-Date)})]
[DateTime]
$EventDate
)
Expand All @@ -524,7 +523,7 @@ In the following example, the value of the variable $date must be greater than
or equal to the current date and time.

```powershell
[DateTime][ValidateScript({$_ -ge (get-date)})]$date = (get-date)
[DateTime][ValidateScript({$_ -ge (Get-Date)})]$date = (Get-Date)
```

## ValidateSet Attribute
Expand Down Expand Up @@ -660,19 +659,19 @@ function Get-Sample {
{
if ($path -match ".HKLM.:")
{
$attributes = new-object -Type `
$attributes = New-Object -Type `
System.Management.Automation.ParameterAttribute
$attributes.ParameterSetName = "__AllParameterSets"
$attributes.Mandatory = $false
$attributeCollection = new-object `
$attributeCollection = New-Object `
-Type System.Collections.ObjectModel.Collection[System.Attribute]
$attributeCollection.Add($attributes)

$dynParam1 = new-object -Type `
$dynParam1 = New-Object -Type `
System.Management.Automation.RuntimeDefinedParameter("dp1", [Int32],
$attributeCollection)

$paramDictionary = new-object `
$paramDictionary = New-Object `
-Type System.Management.Automation.RuntimeDefinedParameterDictionary
$paramDictionary.Add("dp1", $dynParam1)
return $paramDictionary
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
---
---
ms.date: 11/28/2017
schema: 2.0.0
locale: en-us
keywords: powershell,cmdlet
title: about_Functions_CmdletBindingAttribute
---

# About Functions CmdletBindingAttribute

# SHORT DESCRIPTION
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
---
---
ms.date: 01/03/2018
schema: 2.0.0
locale: en-us
keywords: powershell,cmdlet
title: about_Functions_OutputTypeAttribute
---

# About Functions OutputTypeAttribute

## SHORT DESCRIPTION
Expand Down Expand Up @@ -121,7 +120,7 @@ function Send-Greeting
To see the resulting output type property, use the Get-Command cmdlet.

```
PS C:> (Get-Command Send-Greeting).OutputType
PS> (Get-Command Send-Greeting).OutputType

Name Type
---- ----
Expand Down Expand Up @@ -178,15 +177,15 @@ function Get-Time
The Get-Type method confirms that the function returns a string.

```
PS C:> (Get-Time -DateTime (Get-Date)).Gettype().FullName
PS> (Get-Time -DateTime (Get-Date)).Gettype().FullName
System.String
```

However, the OutputType property, which gets its value from the OutputType
attribute, reports that the function returns a DateTime object.

```
PS C:> (Get-Command Get-Time).OutputType
PS> (Get-Command Get-Time).OutputType

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

# About Group Policy Settings

# SHORT DESCRIPTION
Expand Down Expand Up @@ -101,8 +100,8 @@ The module must be imported into the session and the setting is effective
only in the current session.

```powershell
PS C:> Import-Module <Module-Name>
PS C:> (Get-Module <Module-Name>).LogPipelineExecutionDetails = $true
PS> Import-Module <Module-Name>
PS> (Get-Module <Module-Name>).LogPipelineExecutionDetails = $true
```

To turn on module logging for all sessions on a particular computer,
Expand Down
59 changes: 29 additions & 30 deletions reference/3.0/Microsoft.PowerShell.Core/About/about_Hash_Tables.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
---
---
ms.date: 11/28/2017
schema: 2.0.0
locale: en-us
keywords: powershell,cmdlet
title: about_Hash_Tables
---

# About Hash Tables

## SHORT DESCRIPTION
Expand Down Expand Up @@ -109,7 +108,7 @@ place the ordered attribute before the variable name, the command fails with
the following error message.

```powershell
PS C:\> [ordered]$hash = @{}
PS> [ordered]$hash = @{}
At line:1 char:1
+ [ordered]$hash = @{}
+ [!INCLUDE[]()]
Expand All @@ -122,17 +121,17 @@ eption
To correct the expression, move the [ordered] attribute.

```powershell
PS C:\> $hash = [ordered]@{}
PS> $hash = [ordered]@{}
```

You can cast an ordered dictionary to a hash table, but you cannot recover the
ordered attribute, even if you clear the variable and enter new values. To
re-establish the order, you must remove and recreate the variable.

```
PS C:\> [hashtable]$hash = [ordered]@{
PS> [hashtable]$hash = [ordered]@{
>> Number = 1; Shape = "Square"; Color = "Blue"}
PS C:\> $hash
PS> $hash

Name Value
---- -----
Expand All @@ -148,7 +147,7 @@ By default, a hash tables is displayed as a table with one column for keys and
one for values.

```powershell
C:\PS> $hash
PS> $hash

Name Value
---- -----
Expand All @@ -161,12 +160,12 @@ Hash tables have Keys and Values properties. Use dot notation to display all
of the keys or all of the values.

```powershell
C:\PS> $hash.keys
PS> $hash.keys
Number
Shape
Color

C:\PS> $hash.values
PS> $hash.values
1
Square
Blue
Expand All @@ -184,10 +183,10 @@ $hashtable.<key>
For example:

```powershell
C:\PS> $hash.Number
PS> $hash.Number
1

C:\PS> $hash.Color
PS> $hash.Color
Blue
```

Expand All @@ -203,7 +202,7 @@ Hash tables have a Count property that indicates the number of key-value pairs
in the hash table.

```powershell
C:\PS> $hash.count
PS> $hash.count
3
```

Expand All @@ -214,7 +213,7 @@ If the key is a string value, enclose the key name in quotation marks.
For example:

```powershell
C:\PS> $hash["Number"]
PS> $hash["Number"]
1
```

Expand Down Expand Up @@ -296,28 +295,28 @@ The following statement creates a hash table of process name strings and
process object values and saves it in the \$p variable.

```powershell
$p = @{"PowerShell" = (get-process PowerShell);
"Notepad" = (get-process notepad)}
$p = @{"PowerShell" = (Get-Process PowerShell);
"Notepad" = (Get-Process notepad)}
```

You can display the hash table in \$p and use the key-name properties to
display the values.

```powershell
C:\PS> $p
PS> $p

Name Value
---- -----
PowerShell System.Diagnostics.Process (PowerShell)
Notepad System.Diagnostics.Process (notepad)

C:\PS> $p.PowerShell
PS> $p.PowerShell

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
441 24 54196 54012 571 5.10 1788 PowerShell

C:\PS> $p.keys | foreach {$p.$_.handles}
PS> $p.keys | ForEach-Object {$p.$_.handles}
441
251
```
Expand All @@ -328,30 +327,30 @@ Service object that represents the WinRM service, and the value is the current
status of the service.

```powershell
C:\PS> $p = $p + @{(Get-Service WinRM) = ((Get-Service WinRM).Status)}
PS> $p = $p + @{(Get-Service WinRM) = ((Get-Service WinRM).Status)}
```

You can display and access the new key/value pair by using the same methods
that you use for other pairs in the hash table.

```powershell
C:\PS> $p
PS> $p

Name Value
---- -----
PowerShell System.Diagnostics.Process (PowerShell)
Notepad System.Diagnostics.Process (notepad)
System.ServiceProcess.Servi... Running

C:\PS> $p.keys
PS> $p.keys
PowerShell
Notepad

Status Name DisplayName
------ ---- -----------
Running winrm Windows Remote Management (WS-Manag...

C:\PS> $p.keys | foreach {$_.name}
PS> $p.keys | ForEach-Object {$_.name}
winrm
```

Expand All @@ -361,13 +360,13 @@ in which the key is a string, Hash2, and the value is a hash table with three
key/value pairs.

```powershell
C:\PS> $p = $p + @{"Hash2"= @{a=1; b=2; c=3}}
PS> $p = $p + @{"Hash2"= @{a=1; b=2; c=3}}
```

You can display and access the new values by using the same methods.

```powershell
C:\PS> $p
PS> $p

Name Value
---- -----
Expand All @@ -376,15 +375,15 @@ Notepad System.Diagnostics.Process (notepad)
System.ServiceProcess.Servi... Running
Hash2 {a, b, c}

C:\PS> $p.Hash2
PS> $p.Hash2

Name Value
---- -----
a 1
b 2
c 3

C:\PS> $p.Hash2.b
PS> $p.Hash2.b
2
```

Expand All @@ -401,7 +400,7 @@ For example, the following commands enumerate the keys and values in the hash
table in the \$p variable and then sort the keys in alphabetical order.

```powershell
C:\PS> $p.GetEnumerator() | Sort-Object -Property key
PS> $p.GetEnumerator() | Sort-Object -Property key

Name Value
---- -----
Expand All @@ -414,7 +413,7 @@ The following command uses the same procedure to sort the hash values in
descending order.

```powershell
C:\PS> $p.getenumerator() | Sort-Object -Property Value -Descending
PS> $p.getenumerator() | Sort-Object -Property Value -Descending

Name Value
---- -----
Expand Down Expand Up @@ -463,7 +462,7 @@ The following command creates a here-string of the key/value pairs and then
saves it in the \$string variable.

```powershell
C:\PS> $string = @"
PS> $string = @"
Msg1 = Type "Windows".
Msg2 = She said, "Hello, World."
Msg3 = Enter an alias (or "nickname").
Expand All @@ -474,7 +473,7 @@ This command uses the ConvertFrom-StringData cmdlet to convert the here-string
into a hash table.

```powershell
C:\PS> ConvertFrom-StringData $string
PS> ConvertFrom-StringData $string

Name Value
---- -----
Expand Down
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_History
---

# About History

## Short Description
Expand Down
Loading