Using providers

As we saw 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.

PowerShell Core: The certificate provider

The parameters shown next have been removed from PowerShell Core but may return in time. In the meantime, the examples here are valid for Windows PowerShell.

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:

Get-ChildItem Cert:LocalMachineRoot -ExpiringInDays 730
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.5.68