Skip to content

Commit a7a1533

Browse files
authored
Describe behavior of Local scope modifier (#12666)
1 parent 01f1236 commit a7a1533

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

reference/5.1/Microsoft.PowerShell.Core/About/about_Scopes.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Explains the concept of scope in PowerShell and shows how to set and change the scope of elements.
33
Locale: en-US
4-
ms.date: 02/02/2025
4+
ms.date: 01/16/2026
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_scopes?view=powershell-5.1&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about_Scopes
@@ -124,7 +124,10 @@ optional scope modifiers:
124124

125125
- `Global:` - Specifies that the name exists in the **Global** scope.
126126
- `Local:` - Specifies that the name exists in the **Local** scope. The current
127-
scope is always the **Local** scope.
127+
scope is always the **Local** scope. When you use the `Local:` scope
128+
modifier, PowerShell doesn't search parent scopes. If the item exists in the
129+
current scope, it's used. If the item doesn't exist in the current scope,
130+
PowerShell creates a new item in the current scope.
128131
- `Private:` - Specifies that the name is **Private** and only visible to the
129132
current scope.
130133

reference/7.4/Microsoft.PowerShell.Core/About/about_Scopes.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Explains the concept of scope in PowerShell and shows how to set and change the scope of elements.
33
Locale: en-US
4-
ms.date: 02/02/2025
4+
ms.date: 01/16/2026
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_scopes?view=powershell-7.4&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about_Scopes
@@ -124,7 +124,10 @@ optional scope modifiers:
124124

125125
- `Global:` - Specifies that the name exists in the **Global** scope.
126126
- `Local:` - Specifies that the name exists in the **Local** scope. The current
127-
scope is always the **Local** scope.
127+
scope is always the **Local** scope. When you use the `Local:` scope
128+
modifier, PowerShell doesn't search parent scopes. If the item exists in the
129+
current scope, it's used. If the item doesn't exist in the current scope,
130+
PowerShell creates a new item in the current scope.
128131
- `Private:` - Specifies that the name is **Private** and only visible to the
129132
current scope.
130133

reference/7.5/Microsoft.PowerShell.Core/About/about_Scopes.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Explains the concept of scope in PowerShell and shows how to set and change the scope of elements.
33
Locale: en-US
4-
ms.date: 02/02/2025
4+
ms.date: 01/16/2026
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_scopes?view=powershell-7.5&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about_Scopes
@@ -124,7 +124,10 @@ optional scope modifiers:
124124

125125
- `Global:` - Specifies that the name exists in the **Global** scope.
126126
- `Local:` - Specifies that the name exists in the **Local** scope. The current
127-
scope is always the **Local** scope.
127+
scope is always the **Local** scope. When you use the `Local:` scope
128+
modifier, PowerShell doesn't search parent scopes. If the item exists in the
129+
current scope, it's used. If the item doesn't exist in the current scope,
130+
PowerShell creates a new item in the current scope.
128131
- `Private:` - Specifies that the name is **Private** and only visible to the
129132
current scope.
130133

reference/7.6/Microsoft.PowerShell.Core/About/about_Scopes.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Explains the concept of scope in PowerShell and shows how to set and change the scope of elements.
33
Locale: en-US
4-
ms.date: 02/02/2025
4+
ms.date: 01/16/2026
55
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_scopes?view=powershell-7.6&WT.mc_id=ps-gethelp
66
schema: 2.0.0
77
title: about_Scopes
@@ -124,7 +124,10 @@ optional scope modifiers:
124124

125125
- `Global:` - Specifies that the name exists in the **Global** scope.
126126
- `Local:` - Specifies that the name exists in the **Local** scope. The current
127-
scope is always the **Local** scope.
127+
scope is always the **Local** scope. When you use the `Local:` scope
128+
modifier, PowerShell doesn't search parent scopes. If the item exists in the
129+
current scope, it's used. If the item doesn't exist in the current scope,
130+
PowerShell creates a new item in the current scope.
128131
- `Private:` - Specifies that the name is **Private** and only visible to the
129132
current scope.
130133

0 commit comments

Comments
 (0)