From f85eb3c6030985287fff6d97471fa89c396fa8ef Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Tue, 19 Sep 2023 14:17:08 -0500 Subject: [PATCH] Update slash character description --- .../About/about_Locations.md | 65 +++++++++--------- .../About/about_Path_Syntax.md | 50 ++++++++------ .../About/about_Locations.md | 67 +++++++++---------- .../About/about_Path_Syntax.md | 50 ++++++++------ .../About/about_Locations.md | 67 +++++++++---------- .../About/about_Path_Syntax.md | 50 ++++++++------ .../About/about_Locations.md | 67 +++++++++---------- .../About/about_Path_Syntax.md | 50 ++++++++------ 8 files changed, 251 insertions(+), 215 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Locations.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Locations.md index e10f74e8c6e3..38cc15f381ee 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Locations.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Locations.md @@ -1,7 +1,7 @@ --- description: Describes how to access items from the working location in PowerShell. Locale: en-US -ms.date: 03/15/2021 +ms.date: 09/19/2023 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_locations?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 title: about Locations @@ -10,45 +10,44 @@ title: about Locations # about_Locations ## Short description + Describes how to access items from the working location in PowerShell. ## Long description The current working location is the default location to which commands point. -In other words, this is the location that PowerShell uses if you do not supply -an explicit path to the item or location that is affected by the command. +In other words, this is the location that PowerShell uses if you don't supply +an explicit path to the item or location that's affected by the command. > [!NOTE] > PowerShell supports multiple runspaces per process. Each runspace has its own -> _current directory_. This is not the same as the current directory of the -> process: `[System.Environment]::CurrentDirectory`. +> _current directory_. This isn't the same as the current directory of the +> PowerShell process: `[System.Environment]::CurrentDirectory`. -In most cases, the current working location is a drive accessed through the -PowerShell FileSystem provider and, in some cases, a directory on that drive. For example, you might set your current working location to the following location: ```powershell -C:\Program Files\Windows PowerShell +Set-Location C:\Program Files\Windows PowerShell ``` As a result, all commands are processed from this location unless another path is explicitly provided. PowerShell maintains the current working location for each drive even when the -drive is not the current drive. This allows you to access items from the +drive isn't the current drive. This allows you to access items from the current working location by referring only to the drive of another location. For example, suppose that your current working location is `C:\Windows`. Now, suppose you use the following command to change your current working location -to the HKLM: drive: +to the `HKLM:` drive: ```powershell Set-Location HKLM: ``` Although your current location is now the registry drive, you can still access -items in the `C:\Windows` directory simply by using the C: drive, as shown in -the following example: +items in the `C:\Windows` directory using the `C:` drive, as shown in the +following example: ```powershell Get-ChildItem C: @@ -62,34 +61,34 @@ would be the same if you ran the following command: Get-ChildItem C:\Windows ``` -In PowerShell, you can use the Get-Location command to determine the current -working location, and you can use the Set-Location command to set the current +In PowerShell, you can use the `Get-Location` command to determine the current +working location, and you can use the `Set-Location` command to set the current working location. For example, the following command sets the current working -location to the Windows directory of the C: drive: +location to the `Windows` directory of the `C:` drive: ```powershell -Set-Location c:\windows +Set-Location C:\Windows ``` After you set the current working location, you can still access items from -other drives simply by including the drive name (followed by a colon) in the -command, as shown in the following example: +other drives by including the drive name (followed by a colon) in the command, +as shown in the following example: ```powershell Get-ChildItem HKLM:\software ``` The example command retrieves a list of items in the Software container of the -HKEY Local Machine hive in the registry. +`HKEY_LOCAL_MACHINE` hive in the registry. PowerShell also allows you to use special characters to represent the current working location and its parent location. To represent the current working location, use a single period. To represent the parent of the current working -location, use two periods. For example, the following specifies the System +location, use two periods. For example, the following specifies the `System` subdirectory in the current working location: ```powershell -Get-ChildItem .\system +Get-ChildItem .\System ``` If the current working location is `C:\Windows`, this command returns a list of @@ -98,32 +97,32 @@ parent directory of the current working directory is used, as shown in the following example: ```powershell -Get-ChildItem ..\"program files" +Get-ChildItem ..\"Program Files" ``` In this case, PowerShell treats the two periods as the C: drive, so the command retrieves all the items in the `C:\Program Files` directory. -A path beginning with a slash identifies a path from the root of the current -drive. For example, if your current working location is -`C:\Program Files\PowerShell`, the root of your drive is C. Therefore, the +A path beginning with a backslash (`\`) identifies a path from the root of the +current drive. For example, if your current working location is +`C:\Program Files\PowerShell`, the root of your drive is `C:\`. Therefore, the following command lists all items in the `C:\Windows` directory: ```powershell -Get-ChildItem \windows +Get-ChildItem \Windows ``` -If you do not specify a path beginning with a drive name, slash, or period -when supplying the name of a container or item, the container or item is -assumed to be located in the current working location. For example, if your -current working location is `C:\Windows`, the following command returns all the -items in the `C:\Windows\System` directory: +If you don't specify a path beginning with a drive name, backslash (`\`), or +period (`.`) when supplying the name of a container or item, the container or +item is assumed to be located in the current working location. For example, if +your current working location is `C:\Windows`, the following command returns +all the items in the `C:\Windows\System` directory: ```powershell -Get-ChildItem system +Get-ChildItem System ``` -If you specify a file name rather than a directory name, PowerShell returns +If you specify a filename rather than a directory name, PowerShell returns details about that file (assuming that file is located in the current working location). diff --git a/reference/5.1/Microsoft.PowerShell.Core/About/about_Path_Syntax.md b/reference/5.1/Microsoft.PowerShell.Core/About/about_Path_Syntax.md index 48004194f312..0696caaf0381 100644 --- a/reference/5.1/Microsoft.PowerShell.Core/About/about_Path_Syntax.md +++ b/reference/5.1/Microsoft.PowerShell.Core/About/about_Path_Syntax.md @@ -1,7 +1,7 @@ --- description: Describes the full and relative path formats in PowerShell. Locale: en-US -ms.date: 08/29/2022 +ms.date: 09/16/2023 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_path_syntax?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 title: about Path Syntax @@ -18,10 +18,9 @@ uniquely identified by their path names. A path is a combination of the item name, the container and subcontainers in which the item is located, and the PowerShell drive through which the containers are accessed. -In PowerShell, path names are divided into one of two types: fully qualified -and relative. A fully qualified path consists of all elements that make -up a path. The following syntax shows the elements in a fully qualified path -name: +In PowerShell, pathnames can be one of two types: _fully qualified_ and +_relative_. A fully qualified path consists of all elements that make up a +path. The following syntax shows the elements in a fully qualified path name: ```Syntax [::]:[\[\...]]\ @@ -33,32 +32,38 @@ access the files and directories on your computer. This element of the syntax is optional and is never needed because the drive names are unique across all providers. -The `` placeholder refers to the PowerShell drive that's supported by -a particular PowerShell provider. In the case of the FileSystem provider, the -PowerShell drives map to the Windows drives that are configured on your -system. For example, if your system includes an A: drive and a `C:` drive, the +The `` placeholder refers to the PowerShell drive that's supported by a +particular PowerShell provider. In the case of the FileSystem provider, the +PowerShell drives map to the Windows drives that are configured on your system. +For example, if your system includes an `A:` drive and a `C:` drive, the FileSystem provider creates the same drives in PowerShell. After you have specified the drive, you must specify any containers and subcontainers that contain the item. The containers must be specified in the hierarchical order in which they exist in the data store. In other words, you must start with the parent container, then the child container in that parent -container, and so on. In addition, each container must be preceded by a -backslash. (Note that PowerShell allows you to use forward slashes for -compatibility with other PowerShells.) +container, repeating the pattern for each child container. In addition, each +container must be preceded by a backslash. + +> [!NOTE] +> PowerShell allows you to use backslash or forward slash for compatibility +> with PowerShell on other platforms. This works for PowerShell commands, but +> may not work when used with native applications that only expect the native +> directory separator. Use `[System.IO.Path]::DirectorySeparatorChar` to find +> the character used for your platform. After the container and subcontainers have been specified, you must provide the item name, preceded by a backslash. For example, the fully qualified path -name for the Shell.dll file in the `C:\Windows\System32` directory is as +name for the `Shell.dll` file in the `C:\Windows\System32` directory is as follows: ```powershell C:\Windows\System32\Shell.dll ``` -In this case, the drive through which the containers are accessed is the C: -drive, the top-level container is Windows, the subcontainer is System32 -(located within the Windows container), and the item is Shell.dll. +In this case, the drive through which the containers are accessed is the `C:` +drive, the top-level container is `Windows`, the subcontainer is `System32`, +and the item is `Shell.dll`. In some situations, you don't need to specify a fully qualified path and can instead use a relative path. PowerShell allows you to identify an item based on @@ -98,10 +103,10 @@ You get the same results using the fully qualified path: Get-ChildItem C:\TechDocs ``` -Regardless of whether you use a fully qualified path or a relative path -name, a path is important not only because it locates an item but also -because it uniquely identifies the item even if that item shares the same name -as another item in a different container. +Regardless of whether you use a fully qualified path or a relative path name, a +path is important not only because it locates an item but also because it +uniquely identifies the item even if that item shares the same name as another +item in a different container. For instance, suppose that you have two files that are each named `Results.txt`. The first file is in a directory named `C:\TechDocs\Jan`, and @@ -113,3 +118,8 @@ two files. ## See also - [about_Locations](about_Locations.md) +- [Convert-Path](xref:Microsoft.PowerShell.Management.Convert-Path) +- [Join-Path](xref:Microsoft.PowerShell.Management.Join-Path) +- [Resolve-Path](xref:Microsoft.PowerShell.Management.Resolve-Path) +- [Split-Path](xref:Microsoft.PowerShell.Management.Split-Path) +- [Test-Path](xref:Microsoft.PowerShell.Management.Test-Path) diff --git a/reference/7.2/Microsoft.PowerShell.Core/About/about_Locations.md b/reference/7.2/Microsoft.PowerShell.Core/About/about_Locations.md index aa5eac302965..db9c34949c55 100644 --- a/reference/7.2/Microsoft.PowerShell.Core/About/about_Locations.md +++ b/reference/7.2/Microsoft.PowerShell.Core/About/about_Locations.md @@ -1,7 +1,7 @@ --- description: Describes how to access items from the working location in PowerShell. Locale: en-US -ms.date: 03/15/2021 +ms.date: 09/19/2023 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_locations?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 title: about Locations @@ -9,86 +9,85 @@ title: about Locations # about_Locations ## Short description + Describes how to access items from the working location in PowerShell. ## Long description The current working location is the default location to which commands point. -In other words, this is the location that PowerShell uses if you do not supply -an explicit path to the item or location that is affected by the command. +In other words, this is the location that PowerShell uses if you don't supply +an explicit path to the item or location that's affected by the command. > [!NOTE] > PowerShell supports multiple runspaces per process. Each runspace has its own -> _current directory_. This is not the same as the current directory of the -> process: `[System.Environment]::CurrentDirectory`. +> _current directory_. This isn't the same as the current directory of the +> PowerShell process: `[System.Environment]::CurrentDirectory`. -In most cases, the current working location is a drive accessed through the -PowerShell FileSystem provider and, in some cases, a directory on that drive. For example, you might set your current working location to the following location: ```powershell -C:\Program Files\Windows PowerShell +Set-Location C:\Program Files\PowerShell ``` As a result, all commands are processed from this location unless another path is explicitly provided. PowerShell maintains the current working location for each drive even when the -drive is not the current drive. This allows you to access items from the +drive isn't the current drive. This allows you to access items from the current working location by referring only to the drive of another location. For example, suppose that your current working location is `C:\Windows`. Now, suppose you use the following command to change your current working location -to the HKLM: drive: +to the `HKLM:` drive: ```powershell Set-Location HKLM: ``` Although your current location is now the registry drive, you can still access -items in the `C:\Windows` directory simply by using the C: drive, as shown in -the following example: +items in the `C:\Windows` directory using the `C:` drive, as shown in the +following example: ```powershell Get-ChildItem C: ``` PowerShell remembers that your current working location for that drive is the -Windows directory, so it retrieves items from that directory. The results +`Windows` directory, so it retrieves items from that directory. The results would be the same if you ran the following command: ```powershell Get-ChildItem C:\Windows ``` -In PowerShell, you can use the Get-Location command to determine the current -working location, and you can use the Set-Location command to set the current +In PowerShell, you can use the `Get-Location` command to determine the current +working location, and you can use the `Set-Location` command to set the current working location. For example, the following command sets the current working -location to the Windows directory of the C: drive: +location to the `Windows` directory of the `C:` drive: ```powershell -Set-Location c:\windows +Set-Location C:\Windows ``` After you set the current working location, you can still access items from -other drives simply by including the drive name (followed by a colon) in the -command, as shown in the following example: +other drives by including the drive name (followed by a colon) in the command, +as shown in the following example: ```powershell Get-ChildItem HKLM:\software ``` The example command retrieves a list of items in the Software container of the -HKEY Local Machine hive in the registry. +`HKEY_LOCAL_MACHINE` hive in the registry. PowerShell also allows you to use special characters to represent the current working location and its parent location. To represent the current working location, use a single period. To represent the parent of the current working -location, use two periods. For example, the following specifies the System +location, use two periods. For example, the following specifies the `System` subdirectory in the current working location: ```powershell -Get-ChildItem .\system +Get-ChildItem .\System ``` If the current working location is `C:\Windows`, this command returns a list of @@ -97,32 +96,32 @@ parent directory of the current working directory is used, as shown in the following example: ```powershell -Get-ChildItem ..\"program files" +Get-ChildItem ..\"Program Files" ``` In this case, PowerShell treats the two periods as the C: drive, so the command retrieves all the items in the `C:\Program Files` directory. -A path beginning with a slash identifies a path from the root of the current -drive. For example, if your current working location is -`C:\Program Files\PowerShell`, the root of your drive is C. Therefore, the +A path beginning with a backslash (`\`) identifies a path from the root of the +current drive. For example, if your current working location is +`C:\Program Files\PowerShell`, the root of your drive is `C:\`. Therefore, the following command lists all items in the `C:\Windows` directory: ```powershell -Get-ChildItem \windows +Get-ChildItem \Windows ``` -If you do not specify a path beginning with a drive name, slash, or period -when supplying the name of a container or item, the container or item is -assumed to be located in the current working location. For example, if your -current working location is `C:\Windows`, the following command returns all the -items in the `C:\Windows\System` directory: +If you don't specify a path beginning with a drive name, backslash (`\`), or +period (`.`) when supplying the name of a container or item, the container or +item is assumed to be located in the current working location. For example, if +your current working location is `C:\Windows`, the following command returns +all the items in the `C:\Windows\System` directory: ```powershell -Get-ChildItem system +Get-ChildItem System ``` -If you specify a file name rather than a directory name, PowerShell returns +If you specify a filename rather than a directory name, PowerShell returns details about that file (assuming that file is located in the current working location). diff --git a/reference/7.2/Microsoft.PowerShell.Core/About/about_Path_Syntax.md b/reference/7.2/Microsoft.PowerShell.Core/About/about_Path_Syntax.md index 41d265677565..d4ac88c85660 100644 --- a/reference/7.2/Microsoft.PowerShell.Core/About/about_Path_Syntax.md +++ b/reference/7.2/Microsoft.PowerShell.Core/About/about_Path_Syntax.md @@ -1,7 +1,7 @@ --- description: Describes the full and relative path formats in PowerShell. Locale: en-US -ms.date: 08/29/2022 +ms.date: 09/16/2023 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_path_syntax?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 title: about Path Syntax @@ -18,10 +18,9 @@ uniquely identified by their path names. A path is a combination of the item name, the container and subcontainers in which the item is located, and the PowerShell drive through which the containers are accessed. -In PowerShell, path names are divided into one of two types: fully qualified -and relative. A fully qualified path consists of all elements that make -up a path. The following syntax shows the elements in a fully qualified path -name: +In PowerShell, pathnames can be one of two types: _fully qualified_ and +_relative_. A fully qualified path consists of all elements that make up a +path. The following syntax shows the elements in a fully qualified path name: ```Syntax [::]:[\[\...]]\ @@ -33,32 +32,38 @@ access the files and directories on your computer. This element of the syntax is optional and is never needed because the drive names are unique across all providers. -The `` placeholder refers to the PowerShell drive that's supported by -a particular PowerShell provider. In the case of the FileSystem provider, the -PowerShell drives map to the Windows drives that are configured on your -system. For example, if your system includes an A: drive and a `C:` drive, the +The `` placeholder refers to the PowerShell drive that's supported by a +particular PowerShell provider. In the case of the FileSystem provider, the +PowerShell drives map to the Windows drives that are configured on your system. +For example, if your system includes an `A:` drive and a `C:` drive, the FileSystem provider creates the same drives in PowerShell. After you have specified the drive, you must specify any containers and subcontainers that contain the item. The containers must be specified in the hierarchical order in which they exist in the data store. In other words, you must start with the parent container, then the child container in that parent -container, and so on. In addition, each container must be preceded by a -backslash. (Note that PowerShell allows you to use forward slashes for -compatibility with other PowerShells.) +container, repeating the pattern for each child container. In addition, each +container must be preceded by a backslash. + +> [!NOTE] +> PowerShell allows you to use backslash or forward slash for compatibility +> with PowerShell on other platforms. This works for PowerShell commands, but +> may not work when used with native applications that only expect the native +> directory separator. Use `[System.IO.Path]::DirectorySeparatorChar` to find +> the character used for your platform. After the container and subcontainers have been specified, you must provide the item name, preceded by a backslash. For example, the fully qualified path -name for the Shell.dll file in the `C:\Windows\System32` directory is as +name for the `Shell.dll` file in the `C:\Windows\System32` directory is as follows: ```powershell C:\Windows\System32\Shell.dll ``` -In this case, the drive through which the containers are accessed is the C: -drive, the top-level container is Windows, the subcontainer is System32 -(located within the Windows container), and the item is Shell.dll. +In this case, the drive through which the containers are accessed is the `C:` +drive, the top-level container is `Windows`, the subcontainer is `System32`, +and the item is `Shell.dll`. In some situations, you don't need to specify a fully qualified path and can instead use a relative path. PowerShell allows you to identify an item based on @@ -98,10 +103,10 @@ You get the same results using the fully qualified path: Get-ChildItem C:\TechDocs ``` -Regardless of whether you use a fully qualified path or a relative path -name, a path is important not only because it locates an item but also -because it uniquely identifies the item even if that item shares the same name -as another item in a different container. +Regardless of whether you use a fully qualified path or a relative path name, a +path is important not only because it locates an item but also because it +uniquely identifies the item even if that item shares the same name as another +item in a different container. For instance, suppose that you have two files that are each named `Results.txt`. The first file is in a directory named `C:\TechDocs\Jan`, and @@ -113,3 +118,8 @@ two files. ## See also - [about_Locations](about_Locations.md) +- [Convert-Path](xref:Microsoft.PowerShell.Management.Convert-Path) +- [Join-Path](xref:Microsoft.PowerShell.Management.Join-Path) +- [Resolve-Path](xref:Microsoft.PowerShell.Management.Resolve-Path) +- [Split-Path](xref:Microsoft.PowerShell.Management.Split-Path) +- [Test-Path](xref:Microsoft.PowerShell.Management.Test-Path) diff --git a/reference/7.3/Microsoft.PowerShell.Core/About/about_Locations.md b/reference/7.3/Microsoft.PowerShell.Core/About/about_Locations.md index f273a3c167dd..79fc4c04ccb4 100644 --- a/reference/7.3/Microsoft.PowerShell.Core/About/about_Locations.md +++ b/reference/7.3/Microsoft.PowerShell.Core/About/about_Locations.md @@ -1,7 +1,7 @@ --- description: Describes how to access items from the working location in PowerShell. Locale: en-US -ms.date: 03/15/2021 +ms.date: 09/19/2023 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_locations?view=powershell-7.3&WT.mc_id=ps-gethelp schema: 2.0.0 title: about Locations @@ -9,86 +9,85 @@ title: about Locations # about_Locations ## Short description + Describes how to access items from the working location in PowerShell. ## Long description The current working location is the default location to which commands point. -In other words, this is the location that PowerShell uses if you do not supply -an explicit path to the item or location that is affected by the command. +In other words, this is the location that PowerShell uses if you don't supply +an explicit path to the item or location that's affected by the command. > [!NOTE] > PowerShell supports multiple runspaces per process. Each runspace has its own -> _current directory_. This is not the same as the current directory of the -> process: `[System.Environment]::CurrentDirectory`. +> _current directory_. This isn't the same as the current directory of the +> PowerShell process: `[System.Environment]::CurrentDirectory`. -In most cases, the current working location is a drive accessed through the -PowerShell FileSystem provider and, in some cases, a directory on that drive. For example, you might set your current working location to the following location: ```powershell -C:\Program Files\Windows PowerShell +Set-Location C:\Program Files\PowerShell ``` As a result, all commands are processed from this location unless another path is explicitly provided. PowerShell maintains the current working location for each drive even when the -drive is not the current drive. This allows you to access items from the +drive isn't the current drive. This allows you to access items from the current working location by referring only to the drive of another location. For example, suppose that your current working location is `C:\Windows`. Now, suppose you use the following command to change your current working location -to the HKLM: drive: +to the `HKLM:` drive: ```powershell Set-Location HKLM: ``` Although your current location is now the registry drive, you can still access -items in the `C:\Windows` directory simply by using the C: drive, as shown in -the following example: +items in the `C:\Windows` directory using the `C:` drive, as shown in the +following example: ```powershell Get-ChildItem C: ``` PowerShell remembers that your current working location for that drive is the -Windows directory, so it retrieves items from that directory. The results +`Windows` directory, so it retrieves items from that directory. The results would be the same if you ran the following command: ```powershell Get-ChildItem C:\Windows ``` -In PowerShell, you can use the Get-Location command to determine the current -working location, and you can use the Set-Location command to set the current +In PowerShell, you can use the `Get-Location` command to determine the current +working location, and you can use the `Set-Location` command to set the current working location. For example, the following command sets the current working -location to the Windows directory of the C: drive: +location to the `Windows` directory of the `C:` drive: ```powershell -Set-Location c:\windows +Set-Location C:\Windows ``` After you set the current working location, you can still access items from -other drives simply by including the drive name (followed by a colon) in the -command, as shown in the following example: +other drives by including the drive name (followed by a colon) in the command, +as shown in the following example: ```powershell Get-ChildItem HKLM:\software ``` The example command retrieves a list of items in the Software container of the -HKEY Local Machine hive in the registry. +`HKEY_LOCAL_MACHINE` hive in the registry. PowerShell also allows you to use special characters to represent the current working location and its parent location. To represent the current working location, use a single period. To represent the parent of the current working -location, use two periods. For example, the following specifies the System +location, use two periods. For example, the following specifies the `System` subdirectory in the current working location: ```powershell -Get-ChildItem .\system +Get-ChildItem .\System ``` If the current working location is `C:\Windows`, this command returns a list of @@ -97,32 +96,32 @@ parent directory of the current working directory is used, as shown in the following example: ```powershell -Get-ChildItem ..\"program files" +Get-ChildItem ..\"Program Files" ``` In this case, PowerShell treats the two periods as the C: drive, so the command retrieves all the items in the `C:\Program Files` directory. -A path beginning with a slash identifies a path from the root of the current -drive. For example, if your current working location is -`C:\Program Files\PowerShell`, the root of your drive is C. Therefore, the +A path beginning with a backslash (`\`) identifies a path from the root of the +current drive. For example, if your current working location is +`C:\Program Files\PowerShell`, the root of your drive is `C:\`. Therefore, the following command lists all items in the `C:\Windows` directory: ```powershell -Get-ChildItem \windows +Get-ChildItem \Windows ``` -If you do not specify a path beginning with a drive name, slash, or period -when supplying the name of a container or item, the container or item is -assumed to be located in the current working location. For example, if your -current working location is `C:\Windows`, the following command returns all the -items in the `C:\Windows\System` directory: +If you don't specify a path beginning with a drive name, backslash (`\`), or +period (`.`) when supplying the name of a container or item, the container or +item is assumed to be located in the current working location. For example, if +your current working location is `C:\Windows`, the following command returns +all the items in the `C:\Windows\System` directory: ```powershell -Get-ChildItem system +Get-ChildItem System ``` -If you specify a file name rather than a directory name, PowerShell returns +If you specify a filename rather than a directory name, PowerShell returns details about that file (assuming that file is located in the current working location). diff --git a/reference/7.3/Microsoft.PowerShell.Core/About/about_Path_Syntax.md b/reference/7.3/Microsoft.PowerShell.Core/About/about_Path_Syntax.md index 3c9c144e1274..9ef8888ff3dc 100644 --- a/reference/7.3/Microsoft.PowerShell.Core/About/about_Path_Syntax.md +++ b/reference/7.3/Microsoft.PowerShell.Core/About/about_Path_Syntax.md @@ -1,7 +1,7 @@ --- description: Describes the full and relative path formats in PowerShell. Locale: en-US -ms.date: 08/29/2022 +ms.date: 09/16/2023 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_path_syntax?view=powershell-7.3&WT.mc_id=ps-gethelp schema: 2.0.0 title: about Path Syntax @@ -18,10 +18,9 @@ uniquely identified by their path names. A path is a combination of the item name, the container and subcontainers in which the item is located, and the PowerShell drive through which the containers are accessed. -In PowerShell, path names are divided into one of two types: fully qualified -and relative. A fully qualified path consists of all elements that make -up a path. The following syntax shows the elements in a fully qualified path -name: +In PowerShell, pathnames can be one of two types: _fully qualified_ and +_relative_. A fully qualified path consists of all elements that make up a +path. The following syntax shows the elements in a fully qualified path name: ```Syntax [::]:[\[\...]]\ @@ -33,32 +32,38 @@ access the files and directories on your computer. This element of the syntax is optional and is never needed because the drive names are unique across all providers. -The `` placeholder refers to the PowerShell drive that's supported by -a particular PowerShell provider. In the case of the FileSystem provider, the -PowerShell drives map to the Windows drives that are configured on your -system. For example, if your system includes an A: drive and a `C:` drive, the +The `` placeholder refers to the PowerShell drive that's supported by a +particular PowerShell provider. In the case of the FileSystem provider, the +PowerShell drives map to the Windows drives that are configured on your system. +For example, if your system includes an `A:` drive and a `C:` drive, the FileSystem provider creates the same drives in PowerShell. After you have specified the drive, you must specify any containers and subcontainers that contain the item. The containers must be specified in the hierarchical order in which they exist in the data store. In other words, you must start with the parent container, then the child container in that parent -container, and so on. In addition, each container must be preceded by a -backslash. (Note that PowerShell allows you to use forward slashes for -compatibility with other PowerShells.) +container, repeating the pattern for each child container. In addition, each +container must be preceded by a backslash. + +> [!NOTE] +> PowerShell allows you to use backslash or forward slash for compatibility +> with PowerShell on other platforms. This works for PowerShell commands, but +> may not work when used with native applications that only expect the native +> directory separator. Use `[System.IO.Path]::DirectorySeparatorChar` to find +> the character used for your platform. After the container and subcontainers have been specified, you must provide the item name, preceded by a backslash. For example, the fully qualified path -name for the Shell.dll file in the `C:\Windows\System32` directory is as +name for the `Shell.dll` file in the `C:\Windows\System32` directory is as follows: ```powershell C:\Windows\System32\Shell.dll ``` -In this case, the drive through which the containers are accessed is the C: -drive, the top-level container is Windows, the subcontainer is System32 -(located within the Windows container), and the item is Shell.dll. +In this case, the drive through which the containers are accessed is the `C:` +drive, the top-level container is `Windows`, the subcontainer is `System32`, +and the item is `Shell.dll`. In some situations, you don't need to specify a fully qualified path and can instead use a relative path. PowerShell allows you to identify an item based on @@ -98,10 +103,10 @@ You get the same results using the fully qualified path: Get-ChildItem C:\TechDocs ``` -Regardless of whether you use a fully qualified path or a relative path -name, a path is important not only because it locates an item but also -because it uniquely identifies the item even if that item shares the same name -as another item in a different container. +Regardless of whether you use a fully qualified path or a relative path name, a +path is important not only because it locates an item but also because it +uniquely identifies the item even if that item shares the same name as another +item in a different container. For instance, suppose that you have two files that are each named `Results.txt`. The first file is in a directory named `C:\TechDocs\Jan`, and @@ -113,3 +118,8 @@ two files. ## See also - [about_Locations](about_Locations.md) +- [Convert-Path](xref:Microsoft.PowerShell.Management.Convert-Path) +- [Join-Path](xref:Microsoft.PowerShell.Management.Join-Path) +- [Resolve-Path](xref:Microsoft.PowerShell.Management.Resolve-Path) +- [Split-Path](xref:Microsoft.PowerShell.Management.Split-Path) +- [Test-Path](xref:Microsoft.PowerShell.Management.Test-Path) diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_Locations.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_Locations.md index 895cf9a92dcc..797799da1888 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_Locations.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_Locations.md @@ -1,7 +1,7 @@ --- description: Describes how to access items from the working location in PowerShell. Locale: en-US -ms.date: 03/15/2021 +ms.date: 09/19/2023 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_locations?view=powershell-7.4&WT.mc_id=ps-gethelp schema: 2.0.0 title: about Locations @@ -9,86 +9,85 @@ title: about Locations # about_Locations ## Short description + Describes how to access items from the working location in PowerShell. ## Long description The current working location is the default location to which commands point. -In other words, this is the location that PowerShell uses if you do not supply -an explicit path to the item or location that is affected by the command. +In other words, this is the location that PowerShell uses if you don't supply +an explicit path to the item or location that's affected by the command. > [!NOTE] > PowerShell supports multiple runspaces per process. Each runspace has its own -> _current directory_. This is not the same as the current directory of the -> process: `[System.Environment]::CurrentDirectory`. +> _current directory_. This isn't the same as the current directory of the +> PowerShell process: `[System.Environment]::CurrentDirectory`. -In most cases, the current working location is a drive accessed through the -PowerShell FileSystem provider and, in some cases, a directory on that drive. For example, you might set your current working location to the following location: ```powershell -C:\Program Files\Windows PowerShell +Set-Location C:\Program Files\PowerShell ``` As a result, all commands are processed from this location unless another path is explicitly provided. PowerShell maintains the current working location for each drive even when the -drive is not the current drive. This allows you to access items from the +drive isn't the current drive. This allows you to access items from the current working location by referring only to the drive of another location. For example, suppose that your current working location is `C:\Windows`. Now, suppose you use the following command to change your current working location -to the HKLM: drive: +to the `HKLM:` drive: ```powershell Set-Location HKLM: ``` Although your current location is now the registry drive, you can still access -items in the `C:\Windows` directory simply by using the C: drive, as shown in -the following example: +items in the `C:\Windows` directory using the `C:` drive, as shown in the +following example: ```powershell Get-ChildItem C: ``` PowerShell remembers that your current working location for that drive is the -Windows directory, so it retrieves items from that directory. The results +`Windows` directory, so it retrieves items from that directory. The results would be the same if you ran the following command: ```powershell Get-ChildItem C:\Windows ``` -In PowerShell, you can use the Get-Location command to determine the current -working location, and you can use the Set-Location command to set the current +In PowerShell, you can use the `Get-Location` command to determine the current +working location, and you can use the `Set-Location` command to set the current working location. For example, the following command sets the current working -location to the Windows directory of the C: drive: +location to the `Windows` directory of the `C:` drive: ```powershell -Set-Location c:\windows +Set-Location C:\Windows ``` After you set the current working location, you can still access items from -other drives simply by including the drive name (followed by a colon) in the -command, as shown in the following example: +other drives by including the drive name (followed by a colon) in the command, +as shown in the following example: ```powershell Get-ChildItem HKLM:\software ``` The example command retrieves a list of items in the Software container of the -HKEY Local Machine hive in the registry. +`HKEY_LOCAL_MACHINE` hive in the registry. PowerShell also allows you to use special characters to represent the current working location and its parent location. To represent the current working location, use a single period. To represent the parent of the current working -location, use two periods. For example, the following specifies the System +location, use two periods. For example, the following specifies the `System` subdirectory in the current working location: ```powershell -Get-ChildItem .\system +Get-ChildItem .\System ``` If the current working location is `C:\Windows`, this command returns a list of @@ -97,32 +96,32 @@ parent directory of the current working directory is used, as shown in the following example: ```powershell -Get-ChildItem ..\"program files" +Get-ChildItem ..\"Program Files" ``` In this case, PowerShell treats the two periods as the C: drive, so the command retrieves all the items in the `C:\Program Files` directory. -A path beginning with a slash identifies a path from the root of the current -drive. For example, if your current working location is -`C:\Program Files\PowerShell`, the root of your drive is C. Therefore, the +A path beginning with a backslash (`\`) identifies a path from the root of the +current drive. For example, if your current working location is +`C:\Program Files\PowerShell`, the root of your drive is `C:\`. Therefore, the following command lists all items in the `C:\Windows` directory: ```powershell -Get-ChildItem \windows +Get-ChildItem \Windows ``` -If you do not specify a path beginning with a drive name, slash, or period -when supplying the name of a container or item, the container or item is -assumed to be located in the current working location. For example, if your -current working location is `C:\Windows`, the following command returns all the -items in the `C:\Windows\System` directory: +If you don't specify a path beginning with a drive name, backslash (`\`), or +period (`.`) when supplying the name of a container or item, the container or +item is assumed to be located in the current working location. For example, if +your current working location is `C:\Windows`, the following command returns +all the items in the `C:\Windows\System` directory: ```powershell -Get-ChildItem system +Get-ChildItem System ``` -If you specify a file name rather than a directory name, PowerShell returns +If you specify a filename rather than a directory name, PowerShell returns details about that file (assuming that file is located in the current working location). diff --git a/reference/7.4/Microsoft.PowerShell.Core/About/about_Path_Syntax.md b/reference/7.4/Microsoft.PowerShell.Core/About/about_Path_Syntax.md index f687f68697b3..90d5b9f23242 100644 --- a/reference/7.4/Microsoft.PowerShell.Core/About/about_Path_Syntax.md +++ b/reference/7.4/Microsoft.PowerShell.Core/About/about_Path_Syntax.md @@ -1,7 +1,7 @@ --- description: Describes the full and relative path formats in PowerShell. Locale: en-US -ms.date: 08/29/2022 +ms.date: 09/16/2023 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_path_syntax?view=powershell-7.4&WT.mc_id=ps-gethelp schema: 2.0.0 title: about Path Syntax @@ -18,10 +18,9 @@ uniquely identified by their path names. A path is a combination of the item name, the container and subcontainers in which the item is located, and the PowerShell drive through which the containers are accessed. -In PowerShell, path names are divided into one of two types: fully qualified -and relative. A fully qualified path consists of all elements that make -up a path. The following syntax shows the elements in a fully qualified path -name: +In PowerShell, pathnames can be one of two types: _fully qualified_ and +_relative_. A fully qualified path consists of all elements that make up a +path. The following syntax shows the elements in a fully qualified path name: ```Syntax [::]:[\[\...]]\ @@ -33,32 +32,38 @@ access the files and directories on your computer. This element of the syntax is optional and is never needed because the drive names are unique across all providers. -The `` placeholder refers to the PowerShell drive that's supported by -a particular PowerShell provider. In the case of the FileSystem provider, the -PowerShell drives map to the Windows drives that are configured on your -system. For example, if your system includes an A: drive and a `C:` drive, the +The `` placeholder refers to the PowerShell drive that's supported by a +particular PowerShell provider. In the case of the FileSystem provider, the +PowerShell drives map to the Windows drives that are configured on your system. +For example, if your system includes an `A:` drive and a `C:` drive, the FileSystem provider creates the same drives in PowerShell. After you have specified the drive, you must specify any containers and subcontainers that contain the item. The containers must be specified in the hierarchical order in which they exist in the data store. In other words, you must start with the parent container, then the child container in that parent -container, and so on. In addition, each container must be preceded by a -backslash. (Note that PowerShell allows you to use forward slashes for -compatibility with other PowerShells.) +container, repeating the pattern for each child container. In addition, each +container must be preceded by a backslash. + +> [!NOTE] +> PowerShell allows you to use backslash or forward slash for compatibility +> with PowerShell on other platforms. This works for PowerShell commands, but +> may not work when used with native applications that only expect the native +> directory separator. Use `[System.IO.Path]::DirectorySeparatorChar` to find +> the character used for your platform. After the container and subcontainers have been specified, you must provide the item name, preceded by a backslash. For example, the fully qualified path -name for the Shell.dll file in the `C:\Windows\System32` directory is as +name for the `Shell.dll` file in the `C:\Windows\System32` directory is as follows: ```powershell C:\Windows\System32\Shell.dll ``` -In this case, the drive through which the containers are accessed is the C: -drive, the top-level container is Windows, the subcontainer is System32 -(located within the Windows container), and the item is Shell.dll. +In this case, the drive through which the containers are accessed is the `C:` +drive, the top-level container is `Windows`, the subcontainer is `System32`, +and the item is `Shell.dll`. In some situations, you don't need to specify a fully qualified path and can instead use a relative path. PowerShell allows you to identify an item based on @@ -98,10 +103,10 @@ You get the same results using the fully qualified path: Get-ChildItem C:\TechDocs ``` -Regardless of whether you use a fully qualified path or a relative path -name, a path is important not only because it locates an item but also -because it uniquely identifies the item even if that item shares the same name -as another item in a different container. +Regardless of whether you use a fully qualified path or a relative path name, a +path is important not only because it locates an item but also because it +uniquely identifies the item even if that item shares the same name as another +item in a different container. For instance, suppose that you have two files that are each named `Results.txt`. The first file is in a directory named `C:\TechDocs\Jan`, and @@ -113,3 +118,8 @@ two files. ## See also - [about_Locations](about_Locations.md) +- [Convert-Path](xref:Microsoft.PowerShell.Management.Convert-Path) +- [Join-Path](xref:Microsoft.PowerShell.Management.Join-Path) +- [Resolve-Path](xref:Microsoft.PowerShell.Management.Resolve-Path) +- [Split-Path](xref:Microsoft.PowerShell.Management.Split-Path) +- [Test-Path](xref:Microsoft.PowerShell.Management.Test-Path)