Vous êtes sur la page 1sur 9

TOPIC

about_Providers

SHORT DESCRIPTION
Describes how Windows PowerShell providers prov
ide access to data and
components that would not otherwise be easily a
ccessible at the command
line. The data is presented in a consistent for
mat that resembles a file
system drive.

LONG DESCRIPTION
Windows PowerShell providers are Microsoft .NET
Framework-based programs
that make the data in a specialized data store
available in Windows
PowerShell so that you can view and manage it.

The data that a provider exposes appears in a d


rive, and you access the
data in a path like you would on a hard disk dr
ive. You can use any of the
built-in cmdlets that the provider supports to
manage the data in the
provider drive. And, you can use custom cmdlets
that are designed
especially for the data.

The providers can also add dynamic parameters t


o the built-in cmdlets.
These are parameters that are available only wh
en you use the cmdlet with
the provider data.

BUILT-IN PROVIDERS
Windows PowerShell includes a set of built-in p
roviders that you can use
to access the different types of data stores.

Provider Drive Data store


-------- ----- ----------
Alias Alias: Windows PowerShell
aliases

Certificate Cert: x509 certificates f


or digital signatures

Environment Env: Windows environment


variables

FileSystem * File system drives,


directories, and files

Function Function: Windows PowerShell


functions

Registry HKLM:, HKCU Windows registry

Variable Variable: Windows PowerShell


variables

WS-Management WSMan WS-Management confi


guration information

* The FileSystem drives vary on each system.

You can also create your own Windows PowerShell


providers, and you can
install providers that others develop. To list
the providers that are
available in your session, type:

get-psprovider

INSTALLING AND REMOVING PROVIDERS


Windows PowerShell providers are delivered to y
ou in Windows PowerShell
snap-ins, which are .NET Framework-based progra
ms that are compiled
into .dll files. The snap-ins can include provi
ders and cmdlets.

Before you use the provider features, you have


to install the snap-in and
then add it to your Windows PowerShell session.
For more information, see
about_PsSnapins.

You cannot uninstall a provider, although you c


an remove the Windows
PowerShell snap-in for the provider from the cu
rrent session. If you do,
you will remove all the contents of the snap-in
, including its cmdlets.

To remove a provider from the current session,


use the Remove-PsSnapin
cmdlet. This cmdlet does not uninstall the prov
ider, but it makes
the provider unavailable in the session.

You can also use the Remove-PsDrive cmdlet to r


emove any drive from the
current session. This data on the drive is not
affected, but the drive is
no longer available in that session.

VIEWING PROVIDERS
To view the Windows PowerShell providers on you
r computer, type:

get-psprovider
The output lists the built-in providers and the
providers that you added
to the session.

THE PROVIDER CMDLETS


The following cmdlets are designed to work with
the data exposed by
any provider. You can use the same cmdlets in t
he same way to manage
the different types of data that providers expo
se. After you
learn to manage the data of one provider, you c
an use the same
procedures with the data from any provider.

For example, the New-Item cmdlet creates a new


item. In the C: drive that
is supported by the FileSystem provider, you ca
n use New-Item to create a
new file or folder. In the drives that are supp
orted by the Registry
provider, you can use New-Item to create a new
registry key. In the Alias:
drive, you can use New-Item to create a new ali
as.

For detailed information about any of the follo


wing cmdlets, type:

get-help <cmdlet-name> -detailed

CHILDITEM CMDLETS
Get-ChildItem

CONTENT CMDLETS
Add-Content
Clear-Content
Get-Content
Set-Content

ITEM CMDLETS
Clear-Item
Copy-Item
Get-Item
Invoke-Item
Move-Item
New-Item
Remove-Item
Rename-Item
Set-Item

ITEMPROPERTY CMDLETS
Clear-ItemProperty
Copy-ItemProperty
Get-ItemProperty
Move-ItemProperty
New-ItemProperty
Remove-ItemProperty
Rename-ItemProperty
Set-ItemProperty

LOCATION CMDLETS
Get-Location
Pop-Location
Push-Location
Set-Location

PATH CMDLETS
Join-Path
Convert-Path
Split-Path
Resolve-Path
Test-Path

PSDRIVE CMDLETS
Get-PSDrive
New-PSDrive
Remove-PSDrive
PSPROVIDER CMDLETS
Get-PSProvider

VIEWING PROVIDER DATA


The primary benefit of a provider is that it ex
poses its data in a familiar
and consistent way. The model for data presenta
tion is a file system
drive.

To use data that the provider exposes, you view


it, move through it,
and change it as though it were data on a hard
drive. Therefore, the most
important information about a provider is the n
ame of the drive
that it supports.

The drive is listed in the default display of t


he Get-PsProvider cmdlet,
but you can get information about the provider
drive by using the
Get-PsDrive cmdlet. For example, to get all the
properties of the
Function: drive, type:

get-psdrive Function | format-list *

You can view and move through the data in a pro


vider drive just as
you would on a file system drive.

To view the contents of a provider drive, use t


he Get-Item or Get-ChildItem
cmdlets. Type the drive name followed by a colo
n (:). For example, to
view the contents of the Alias: drive, type:
get-item alias:

You can view and manage the data in any drive f


rom another drive by
including the drive name in the path. For examp
le, to view the
HKLM\Software registry key in the HKLM: drive f
rom another drive, type:

get-childitem hklm:\software

To open the drive, use the Set-Location cmdlet.


Remember the colon
when you specify the drive path. For example, t
o change your location
to the root directory of the Cert: drive, type:

set-location cert:

Then, to view the contents of the Cert: drive,


type:

get-childitem

MOVING THROUGH HIERARCHICAL DATA


You can move through a provider drive just as y
ou would a hard disk drive.
If the data is arranged in a hierarchy of items
within items, use a
backslash (\) to indicate a child item. Use the
following format:

drive:\location\child-location\...

For example, to change your location to the HKL


M\Software registry key,
type a Set-Location command, such as:

set-location hklm:\software

You can also use relative references to locatio


ns. A dot (.) represents the
current location. For example, if you are in th
e HKLM:\Software\Microsoft
registry key, and you want to list the registry
subkeys in the
HKLM:\Software\Micrsoft\PowerShell key, type th
e following command:

get-childitem .\powershell

FINDING DYNAMIC PARAMETERS


Dynamic parameters are cmdlet parameters that a
re added to a cmdlet
by a provider. These parameters are available o
nly when the cmdlet is
used with the provider that added them.

For example, the Cert: drive adds the CodeSigni


ngCert parameter
to the Get-Item and Get-ChildItem cmdlets. You
can use this parameter
only when you use Get-Item or Get-ChildItem in
the Cert: drive.

For a list of the dynamic parameters that a pro


vider supports, see the
Help file for the provider. Type:

get-help <provider-name>

For example:
get-help certificate

LEARNING ABOUT PROVIDERS


Although all provider data appears in drives, a
nd you use the same methods
to move through them, the similarity stops ther
e. The data stores that
the provider exposes can be as varied as Active
Directory locations and
Microsoft Exchange Server mailboxes.

For information about individual Windows PowerS


hell providers, type:

get-help <ProviderName>

For example:

get-help registry

For a list of Help topics about the providers,


type:

get-help * -category provider

SEE ALSO
about_Locations
about_Path_Syntax

Vous aimerez peut-être aussi