As seen previously, providers may be accessed in the same way as the filesystem. Commands we might traditionally think of as filesystem commands (such as Get-ChildItem, New and Remove-Item, Get and Set-Acl, and Get and Set-ItemProperty) can work with data presented by a provider.
The list of parameters for the filesystem commands changes depending on the provider. The affected parameters are detailed in the help files for individual providers.
If we look at the FileSystem provider help file (Get-Help FileSystem), we can see that Get-ChildItem has a File switch parameter that can be used to filter files only:
-File <System.Management.Automation.SwitchParameter>
Gets files.
The File parameter was introduced in Windows
PowerShell 3.0.
To get only files, use the File parameter and omit
the
Directory parameter. To exclude files, use the
Directory
parameter and omit the File parameter, or use the
Attributes parameter.
Cmdlets Supported: Get-ChildItem
Let's look at the following example:
Set-Location C: Get-ChildItem -File
Looking at the Certificate provider help file (Get-Help Certificate), a different set of parameters is available. For example, this excerpt shows the ExpiringInDays parameter for Get-ChildItem:
-ExpiringInDays <System.Int32>
Gets certificates that are expiring in or before
the specified number of days. Enter an integer. A
value of 0 (zero) gets certificates that have
expired.
This parameter is valid in all subdirectories of
the Certificate provider, but it is effective only
on certificates.
This parameter was introduced in Windows
PowerShell 3.0.
Cmdlets Supported: Get-ChildItem
The previous parameter may be used to find the Root certificates expiring in the next two years, as shown in the following example:
Set-Location Cert:LocalMachineRoot Get-ChildItem -ExpiringInDays 730
The parameters discussed in each help file are only valid inside a drive based on the provider in question, that is, ExpiringInDays. The previous example will work if the current location is a part of Certificate provider. Attempting to run the command from the C: drive (under the FileSystem provider) results in an error as demonstrated in the following code:
PS C:> Get-ChildItem -Path Cert:LocalMachineRoot -ExpiringInDays 730
Get-ChildItem : A parameter cannot be found that matches parameter name 'ExpiringInDays'.
At line:1 char:45
+ Get-ChildItem -Path Cert:LocalMachineRoot -ExpiringInDays 730
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-ChildItem], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand