Skip to content

Commit

Permalink
Fixes #10689 - Update TOC (#10694)
Browse files Browse the repository at this point in the history
* Update example to use a scriptblock

* Update TOC
  • Loading branch information
sdwheeler authored Nov 30, 2023
1 parent 3d841fb commit 944fe73
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Variables that customize the behavior of PowerShell.
Locale: en-US
ms.date: 09/29/2023
ms.date: 11/30/2023
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_preference_variables?view=powershell-7.3&WT.mc_id=ps-gethelp
schema: 2.0.0
title: about Preference Variables
Expand Down Expand Up @@ -1065,16 +1065,20 @@ information other than errors. In these cases, you can temporarily disable the
behavior and prevent non-zero exit codes from issuing errors.

```powershell
$definedPreference = $PSNativeCommandUseErrorActionPreference
$PSNativeCommandUseErrorActionPreference = $false
robocopy.exe D:\reports\operational "\\reporting\ops" CY2022Q4.md
$robocopyExitCode = $LASTEXITCODE
if ($robocopyExitCode -gt 8) {
throw "robocopy failed with exit code $robocopyExitCode"
& {
# Disable $PSNativeCommandUseErrorActionPreference for this scriptblock
$PSNativeCommandUseErrorActionPreference = $false
robocopy.exe D:\reports\operational "\\reporting\ops" CY2022Q4.md
if ($LASTEXITCODE -gt 8) {
throw "robocopy failed with exit code $LASTEXITCODE"
}
}
$PSNativeCommandUseErrorActionPreference = $definedPreference
```

In this example, the `$PSNativeCommandUseErrorActionPreference` variable is
changed inside a scriptblock. The change is local to the scriptblock. When the
scriptblock exits, the variable reverts to its previous value.

## $PSSessionApplicationName

Specifies the default application name for a remote command that uses Web
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1057,16 +1057,20 @@ information other than errors. In these cases, you can temporarily disable the
behavior and prevent non-zero exit codes from issuing errors.

```powershell
$definedPreference = $PSNativeCommandUseErrorActionPreference
$PSNativeCommandUseErrorActionPreference = $false
robocopy.exe D:\reports\operational "\\reporting\ops" CY2022Q4.md
$robocopyExitCode = $LASTEXITCODE
if ($robocopyExitCode -gt 8) {
throw "robocopy failed with exit code $robocopyExitCode"
& {
# Disable $PSNativeCommandUseErrorActionPreference for this scriptblock
$PSNativeCommandUseErrorActionPreference = $false
robocopy.exe D:\reports\operational "\\reporting\ops" CY2022Q4.md
if ($LASTEXITCODE -gt 8) {
throw "robocopy failed with exit code $LASTEXITCODE"
}
}
$PSNativeCommandUseErrorActionPreference = $definedPreference
```

In this example, the `$PSNativeCommandUseErrorActionPreference` variable is
changed inside a scriptblock. The change is local to the scriptblock. When the
scriptblock exits, the variable reverts to its previous value.

## $PSSessionApplicationName

Specifies the default application name for a remote command that uses Web
Expand Down
13 changes: 5 additions & 8 deletions reference/docs-conceptual/learn/experimental-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,14 @@ Legend
The ANSI formatting features were added in PowerShell 7.2. This feature adds the `$PSStyle.FileInfo`
member and enables coloring of specific file types.

- `$PSStyle.FileInfo.Directory` - Built-in member to specify color for directories
- `$PSStyle.FileInfo.SymbolicLink` - Built-in member to specify color for symbolic links
- `$PSStyle.FileInfo.Executable` - Built-in member to specify color for executables.
- `$PSStyle.FileInfo.Extension` - Use this member to define colors for different file extensions.
The **Extension** member pre-includes extensions for archive and PowerShell files.
- `$PSStyle.FileInfo.Directory` - Built-in member to specify the color for directories
- `$PSStyle.FileInfo.SymbolicLink` - Built-in member to specify the color for symbolic links
- `$PSStyle.FileInfo.Executable` - Built-in member to specify the color for executables.
- `$PSStyle.FileInfo.Extension` - Use this member to define the colors for different file
extensions. The **Extension** member pre-includes extensions for archive and PowerShell files.

For more information, see [about_Automatic_Variables][05].

> [!NOTE]
> This feature is dependent on the **PSAnsiRendering** feature that's now a standard feature.
### PSCommandNotFoundSuggestion

Recommends potential commands based on fuzzy matching search after a **CommandNotFoundException**.
Expand Down
14 changes: 6 additions & 8 deletions reference/docs-conceptual/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,12 @@ items:
items:
- name: Overview
href: whats-new/overview.yml
- name: What's new in PowerShell 7.x
items:
- name: What's new in PowerShell 7.4
href: whats-new/what-s-new-in-powershell-74.md
- name: What's new in PowerShell 7.3
href: whats-new/what-s-new-in-powershell-73.md
- name: What's new in PowerShell 7.2
href: whats-new/what-s-new-in-powershell-72.md
- name: What's new in PowerShell 7.4
href: whats-new/what-s-new-in-powershell-74.md
- name: What's new in PowerShell 7.3
href: whats-new/what-s-new-in-powershell-73.md
- name: What's new in PowerShell 7.2
href: whats-new/what-s-new-in-powershell-72.md
- name: Migrating from Windows PowerShell 5.1 to PowerShell 7
href: whats-new/Migrating-from-Windows-PowerShell-51-to-PowerShell-7.md
- name: Differences between Windows PowerShell 5.1 and PowerShell 7.x
Expand Down
6 changes: 3 additions & 3 deletions reference/docs-conceptual/whats-new/overview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
ms.topic: landing-page
author: sdwheeler
ms.author: sewhee
ms.date: 11/16/2023
ms.date: 11/30/2023

# linkListType: architecture | concept | deploy | download | get-started | how-to-guide | learn |
# overview | quickstart | reference | tutorial | video | whats-new
Expand Down Expand Up @@ -38,8 +38,8 @@ landingContent:
linkLists:
- linkListType: whats-new
links:
- text: What's new in PowerShell 5.1
url: ../windows-powershell/whats-new/what-s-new-in-windows-powershell-50.md
- text: What is Windows PowerShell?
url: ../windows-powershell/overview.md
- text: Differences between Windows PowerShell 5.1 and PowerShell 7
url: ./differences-from-windows-powershell.md
- text: Migrating from Windows PowerShell 5.1 to PowerShell 7
Expand Down

0 comments on commit 944fe73

Please sign in to comment.