Items
Support for each of the *-Item
and *-Path
commands varies from one provider to another. The FileSystem
provider supports all the commands, while the Registry
provider supports a smaller number.
Items accessed using a provider also expose access to .NET methods associated with an item.
Provider commands offer convenience and reduced complexity at the cost of speed. In many cases provider commands have .NET equivalents that are significantly faster at the cost of extra complexity.
One point of extra complexity is handling relative paths.
Paths and .NET
PowerShell allows relative paths to be used with many commands including the provider commands.
For example, the following command will write content to a file in the current directory in PowerShell:
Set-Content file.txt -Value 'Some content'
An equivalent .NET method for the command above is the Exists
method of the System.IO.Path
type:
[System.IO.File]::Exists('file.txt')
However, when the method above is used, the path...