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,7 +1,7 @@
---
description: Describes how to access and manage environment variables in PowerShell.
Locale: en-US
ms.date: 07/17/2023
ms.date: 09/20/2023
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-5.1&WT.mc_id=ps-gethelp
schema: 2.0.0
title: about Environment Variables
Expand Down Expand Up @@ -192,6 +192,12 @@ VERBOSE: Performing the operation "Remove Item" on target "Item: Foo2".
VERBOSE: Performing the operation "Remove Item" on target "Item: Foo".
```

Use the `Get-ChildItem` cmdlet to see a full list of environment variables:

```powershell
Get-ChildItem Env:
```

For more information on using the **Environment** provider to manage
environment variables, see [about_Environment_Provider][04].

Expand Down
47 changes: 36 additions & 11 deletions reference/5.1/Microsoft.PowerShell.Host/Start-Transcript.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,28 @@ This command starts a transcript in the `Transcript0.txt` file in `C:\transcript
**NoClobber** parameter is used, the command prevents any existing files from being overwritten. If
the `Transcript0.txt` file already exists, the command fails.

### Example 3: Start a transcript file with a unique name and store it on a file share

The following example creates a transcript file with a name unique enough to be stored on in a
shared location. The filename is constructed from the user's name, the hostname of the computer
running PowerShell, the version of PowerShell, and the date and time. The transcript is stored in
the `\\Server01\Transcripts` file share.

```powershell
$sharepath = '\\Server01\Transcripts'
$username = $env:USERNAME
$hostname = hostname
$version = $PSVersionTable.PSVersion.ToString()
$datetime = Get-Date -f 'yyyyMMddHHmmss'
$filename = "Transcript-${username}-${hostname}-${version}-${datetime}.txt"
$Transcript = Join-Path -Path $sharepath -ChildPath $filename
Start-Transcript
```

The full path to the transcript file is stored in the `$Transcript` preference variable. For more
information about the `$Transcript` preference variable, see
[about_Preference_Variables](../Microsoft.PowerShell.Core/About/about_Preference_Variables.md#transcript).

## PARAMETERS

### -Append
Expand All @@ -94,7 +116,7 @@ Accept wildcard characters: False
### -Force

Allows the cmdlet to append the transcript to an existing read-only file. When used on a read-only
file, the cmdlet changes the file permission to read-write. The cmdlet cannot override security
file, the cmdlet changes the file permission to read-write. The cmdlet can't override security
restrictions when this parameter is used.

```yaml
Expand Down Expand Up @@ -128,9 +150,9 @@ Accept wildcard characters: False
### -LiteralPath

Specifies a location to the transcript file. Unlike the **Path** parameter, the value of the
**LiteralPath** parameter is used exactly as it is typed. No characters are interpreted as
wildcards. If the path includes escape characters, enclose it in single quotation marks. Single
quotation marks inform PowerShell not to interpret any characters as escape sequences.
**LiteralPath** parameter is used exactly as it's typed. No characters are interpreted as wildcards.
If the path includes escape characters, enclose it in single quotation marks. Single quotation marks
inform PowerShell not to interpret any characters as escape sequences.

```yaml
Type: System.String
Expand All @@ -146,7 +168,7 @@ Accept wildcard characters: False

### -NoClobber

Indicates that this cmdlet does not overwrite an existing file. By default, if a transcript file
Indicates that this cmdlet doesn't overwrite an existing file. By default, if a transcript file
exists in the specified path, `Start-Transcript` overwrites the file without warning.

```yaml
Expand Down Expand Up @@ -180,14 +202,14 @@ Accept wildcard characters: False

### -Path

Specifies a location to the transcript file. Enter a path to a `.txt` file. Wildcards are not
Specifies a location to the transcript file. Enter a path to a `.txt` file. Wildcards aren't
permitted.

If you do not specify a path, `Start-Transcript` uses the path in the value of the `$Transcript`
global variable. If you have not created this variable, `Start-Transcript` stores the transcripts in
If you don't specify a path, `Start-Transcript` uses the path in the value of the `$Transcript`
global variable. If you haven't created this variable, `Start-Transcript` stores the transcripts in
the `$HOME\My Documents directory as \PowerShell_transcript.<time-stamp>.txt` files.

If any of the directories in the path do not exist, the command fails.
If any of the directories in the path don't exist, the command fails.

```yaml
Type: System.String
Expand Down Expand Up @@ -220,7 +242,7 @@ Accept wildcard characters: False
### -WhatIf

Shows what would happen if the cmdlet runs.
The cmdlet is not run.
The cmdlet isn't run.

```yaml
Type: System.Management.Automation.SwitchParameter
Expand All @@ -238,7 +260,8 @@ Accept wildcard characters: False

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
-WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
-WarningAction, and -WarningVariable. For more information, see
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

Expand All @@ -262,3 +285,5 @@ information, see [about_Profiles](../Microsoft.PowerShell.Core/About/about_Profi
## RELATED LINKS

[Stop-Transcript](Stop-Transcript.md)

[about_Preference_Variables](../Microsoft.PowerShell.Core/About/about_Preference_Variables.md#transcript)
20 changes: 19 additions & 1 deletion reference/5.1/Microsoft.PowerShell.Management/Set-Service.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,23 @@ Set-Service -InputObject $S -Status Stopped
in the variable, `$S`. `Set-Service` uses the **InputObject** parameter and specifies the object
stored `$S`. The **Status** parameter sets the service to **Stopped**.

### Example 7: Set the startup type for multiple services

The `Set-Service` cmdlet only accepts one service name at a time. However, you can pipe multiple
services to `Set-Service` to change the configuration of multiple services.

```powershell
Get-Service SQLWriter,spooler |
Set-Service -StartupType Automatic -PassThru |
Select-Object Name, StartType
```

```Output
Name StartType
---- ---------
spooler Automatic
SQLWriter Automatic
```
## PARAMETERS

### -ComputerName
Expand Down Expand Up @@ -351,7 +368,8 @@ Accept wildcard characters: False

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
-WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
-WarningAction, and -WarningVariable. For more information, see
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

Expand Down
57 changes: 29 additions & 28 deletions reference/5.1/Microsoft.PowerShell.Management/Split-Path.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Management
ms.date: 07/31/2023
ms.date: 09/20/2023
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/split-path?view=powershell-5.1&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Split-Path
Expand Down Expand Up @@ -60,7 +60,7 @@ Split-Path -LiteralPath <String[]> [-Resolve] [-Credential <PSCredential>] [-Use
## DESCRIPTION

The `Split-Path` cmdlet returns only the specified part of a path, such as the parent folder, a
subfolder, or a file name. It can also get items that are referenced by the split path and tell
subfolder, or a filename. It can also get items that are referenced by the split path and tell
whether the path is relative or absolute.

You can use this cmdlet to get or submit only a selected part of a path.
Expand All @@ -79,7 +79,7 @@ HKCU:

This command returns only the qualifier of the path. The qualifier is the drive.

### Example 2: Display file names
### Example 2: Display filenames

```powershell
Split-Path -Path "C:\Test\Logs\*.log" -Leaf -Resolve
Expand All @@ -92,25 +92,25 @@ Pass2.log
```

This command displays the files that are referenced by the split path. Because this path is split to
the last item, also known as the leaf, the command displays only the file names.
the last item, also known as the leaf, the command displays only the filenames.

The **Resolve** parameter tells `Split-Path` to display the items that the split path references,
instead of displaying the split path.

Like all `Split-Path` commands, this command returns strings.
It does not return **FileInfo** objects that represent the files.
Like all `Split-Path` commands, this command returns strings. It doesn't return **FileInfo** objects
that represent the files.

### Example 3: Get the parent container

```powershell
Split-Path -Path "C:\WINDOWS\system32\WindowsPowerShell\V1.0\about_*.txt"
Split-Path -Parent "C:\WINDOWS\system32\WindowsPowerShell\V1.0\about_*.txt"
```

```Output
C:\WINDOWS\system32\WindowsPowerShell\V1.0
```

This command returns only the parent containers of the path. Because it does not include any
This command returns only the parent containers of the path. Because it doesn't include any
parameters to specify the split, `Split-Path` uses the split location default, which is **Parent**.

### Example 4: Determines whether a path is absolute
Expand All @@ -124,12 +124,12 @@ False
```

This command determines whether the path is relative or absolute. In this case, because the path is
relative to the current folder, which is represented by a dot (`.`), it returns $False.
relative to the current folder, which is represented by a dot (`.`), it returns `$False`.

### Example 5: Change location to a specified path

```powershell
PS C:> Set-Location (Split-Path -Path $profile)
PS C:\> Set-Location (Split-Path -Path $profile)
PS C:\Documents and Settings\User01\My Documents\WindowsPowerShell>
```

Expand All @@ -140,7 +140,7 @@ built-in `$Profile` variable. The **Parent** parameter is the default split loca
Therefore, you can omit it from the command. The parentheses direct PowerShell to run the command
first. This is a useful way to move to a folder that has a long path name.

### Example 6: Split a path by using the pipeline
### Example 6: Split a path using the pipeline

```powershell
'C:\Documents and Settings\User01\My Documents\My Pictures' | Split-Path
Expand All @@ -150,17 +150,17 @@ first. This is a useful way to move to a folder that has a long path name.
C:\Documents and Settings\User01\My Documents
```

This command uses a pipeline operator (`|`) to send a path to `Split-Path`.
The path is enclosed in quotation marks to indicate that it is a single token.
This command uses a pipeline operator (`|`) to send a path to `Split-Path`. The path is enclosed in
quotation marks to indicate that it's a single token.

## PARAMETERS

### -Credential

> [!NOTE]
> This parameter is not supported by any providers installed with PowerShell.
> To impersonate another user, or elevate your credentials when running this cmdlet,
> use [Invoke-Command](../Microsoft.PowerShell.Core/Invoke-Command.md).
> This parameter isn't supported by any providers installed with PowerShell. To impersonate another
> user, or elevate your credentials when running this cmdlet, use
> [Invoke-Command](../Microsoft.PowerShell.Core/Invoke-Command.md).

```yaml
Type: System.Management.Automation.PSCredential
Expand All @@ -176,8 +176,8 @@ Accept wildcard characters: False

### -IsAbsolute

Indicates that this cmdlet returns `$True` if the path is absolute and $False if it is relative. An
absolute path has a length greater than zero and does not use a dot (`.`) to indicate the current
Indicates that this cmdlet returns `$True` if the path is absolute and `$False` if it's relative. An
absolute path has a length greater than zero and doesn't use a dot (`.`) to indicate the current
path.

```yaml
Expand Down Expand Up @@ -231,8 +231,8 @@ Accept wildcard characters: False
### -NoQualifier

Indicates that this cmdlet returns the path without the qualifier. For the FileSystem or registry
providers, the qualifier is the drive of the provider path, such as C: or HKCU:. For example, in the
path `C:\Test\Logs\Pass1.log`, it returns only \Test\Logs\Pass1.log.
providers, the qualifier is the drive of the provider path, such as `C:` or `HKCU:`. For example, in the
path `C:\Test\Logs\Pass1.log`, it returns only `\Test\Logs\Pass1.log`.

```yaml
Type: System.Management.Automation.SwitchParameter
Expand All @@ -249,7 +249,7 @@ Accept wildcard characters: False
### -Parent

Indicates that this cmdlet returns only the parent containers of the item or of the container
specified by the path. For example, in the path `C:\Test\Logs\Pass1.log`, it returns C:\Test\Logs.
specified by the path. For example, in the path `C:\Test\Logs\Pass1.log`, it returns `C:\Test\Logs`.
The **Parent** parameter is the default split location parameter.

```yaml
Expand Down Expand Up @@ -284,7 +284,7 @@ Accept wildcard characters: True
### -Qualifier

Indicates that this cmdlet returns only the qualifier of the specified path. For the FileSystem or
registry providers, the qualifier is the drive of the provider path, such as C: or HKCU:.
registry providers, the qualifier is the drive of the provider path, such as `C:` or `HKCU:`.

```yaml
Type: System.Management.Automation.SwitchParameter
Expand Down Expand Up @@ -336,7 +336,8 @@ Accept wildcard characters: False

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
-WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
-WarningAction, and -WarningVariable. For more information, see
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

Expand All @@ -349,7 +350,7 @@ You can pipe a string that contains a path to this cmdlet.
### System.String

This cmdlet returns text strings. When you specify the **Resolve** parameter, it returns a
string that describes the location of the items. It does not return objects that represent the
string that describes the location of the items. It doesn't return objects that represent the
items, such as a **FileInfo** or **RegistryKey** object.

### System.Boolean
Expand All @@ -361,16 +362,16 @@ When you specify the **IsAbsolute** parameter, this cmdlet returns a **Boolean**
- The split location parameters (**Qualifier**, **Parent**, **Leaf**, and **NoQualifier**) are
exclusive. You can use only one in each command.

The cmdlets that contain the **Path** noun (the **Path** cmdlets) work with path names and return
the names in a concise format that all PowerShell providers can interpret. They are designed for
- The cmdlets that contain the **Path** noun (the **Path** cmdlets) work with path names and return
the names in a concise format that all PowerShell providers can interpret. They're designed for
use in programs and scripts where you want to display all or part of a path name in a particular
format. Use them in the way that you would use **Dirname**, **Normpath**, **Realpath**, **Join**,
or other path manipulators.

You can use the **Path** cmdlets together with several providers. These include the FileSystem,
- You can use the **Path** cmdlets together with several providers. These include the FileSystem,
Registry, and Certificate providers.

`Split-Path` is designed to work with the data exposed by any provider. To list the providers
- `Split-Path` is designed to work with the data exposed by any provider. To list the providers
available in your session, type `Get-PSProvider`. For more information, see [about_Providers](../Microsoft.PowerShell.Core/About/about_Providers.md).

## RELATED LINKS
Expand Down
Loading