MicrosoftВ® Windows PowerShell(TM) Step By Step (Step By Step (Microsoft))

In this exercise, we explore the use of the Certificate provider in Windows PowerShell.

  1. Start Windows PowerShell.

  2. Obtain a listing of all the properties available for use with the Get-ChildItem cmdlet by piping the results into the Get-Member cmdlet. To filter out only the properties, pipeline the results into a Where-Object cmdlet and specify the membertype to be equal to property. This command is shown here:

    Get-ChildItem |Get-Member | Where-Object {$_.membertype -eq "property"}

  3. Set your location to the certificate drive. To identify the certificate drive, use the Get-PSDrive cmdlet. Use the Where-Object cmdlet and filter on names that begin with the letter c. This is shown here:

    Get-PSDrive |where {$_.name -like "c*"}

  4. The results of this command are shown here:

    Name Provider Root CurrentLocation ---- -------- ---- --------------- C FileSystem C:\ cert Certificate \

  5. Use the Set-Location cmdlet to change to the certificate drive.

    Sl cert:\

  6. Use the Get-ChildItem cmdlet to produce a listing of all the certificates on the machine.

    GCI

  7. The output from the previous command is shown here:

    Location : CurrentUser StoreNames : {?, UserDS, AuthRoot, CA...} Location : LocalMachine StoreNames : {?, AuthRoot, CA, AddressBook...}

  8. The listing seems somewhat incomplete. To determine whether there are additional certificates installed on the machine, use the Get-ChildItem cmdlet again, but this time specify the recurse argument. Modify the previous command by using the up arrow. The command is shown here:

    GCI -recurse

  9. The output from the previous command seems to take a long time to run and produces hundreds of lines of output. To make the listing more readable, pipe the output to a text file, and then open the file in Notepad. The command to do this is shown here:

    GCI -recurse >C:\a.txt;notepad.exe a.txt

  10. This concludes this step-by-step exercise.

Категории