PowerShell Providers

PowerShell Tutorial 5: Windows PowerShell Providers


PowerShell Providers are .NET programs that allow us to work with data stores as if they were mounted drives. This simplifies accessing external data outside the PowerShell environment. For example, we can access the registry as if it were a file system. This translates to being able to use the same cmdlets as working with files and folders, which are shown in the table below.

Cmdlet Alias Cmd Commands Descritption
Get-Location gl pwd Current Directory.
Set-Location sl cd, chdir Change current directory.
Copy-Item cpi copy Copy Files.
Remove-Item ri del Removes a File or directory.
Move-Item mi move Move a file.
Rename-Item rni rn Rename a file.
New-Item ni n/a Creates a new empty file or folder.
Clear-Item cli n/a Clears the contents of a file.
Set-Item si n/a Set the contents of a file.
Mkdir n/a md Creates a new directory.
Get-Content gc type Sends contents of a file to the output stream.
Set-Content sc n/a Set the contents of a file.

Take a look at the “about file” for more information:

Get-Content $PSHOME\about_Provider.help.txt<enter>

SHORT DESCRIPTION
Windows PowerShell providers provide access to data and components that
would not otherwise be easily accessible at the command line. The data
is presented in a consistent format that resembles a file system drive.

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

The data that a provider exposes appears in a drive, much like a hard drive.
You can use any of the built-in cmdlets that the provider supports to manage
the data in the provider drive, in addition to custom cmdlets that are
designed especially for the data.

The providers can also add “dynamic parameters” to the built-in cmdlets.
These are parameters that are available only when using the cmdlet with the
provider data.

A Provider is also called a “snap-in” which is a dynamic link library (.dll) built into PowerShell. A library is code that instructs PowerShell to preform an action when we execute a command. What this means is that we no longer have to write code, as we did in VBScript, to connect to the registry. The code is provided for us, simplifying our efforts. New and Custom Providers can be written, but this goes beyond the scope of this tutorial. The PowerShell Software Developers Kit provides documents should you wish to build your own Providers.

List Providers available in PowerShell

Using the “Get-PSProvider” cmdlet, we obtain a list of available PowerShell Providers:

Get-PSProvider<enter>
PowerShell Training PSProvider Image

PowerShell Providers

Image 5.0

Here is the list of the PoweShell Providers available:

  • Alias
  • Environment
  • FileSystem
  • Function
  • Registry
  • Variable
  • Certificate

PowerShell Drive “PSDrive”

We connect to PowerShell Providers by mounting the Providers PowerShell Drive(PSDrive). Most Providers have only one PSDrive, the exceptions are the FileSystem Provider(depends on the number of drives on the system) and the Registry Provider(HKLM and HKCU). Here is how to get a list of the available PowerShell Drives:

Get-PSDrive<enter>
PowerShell Training PSdrive

PS Drives

Image 5.1

The “Name” column reveals the PSDrives available on the system. We connect to each Provider using the PSDrive appended with a colon (:). Note: The example in image 5.1 shows the PSDrives without the (:) so you have to remember to use it when mounting a PSDrive.

Let’s use this PowerShell training session to explore each of these providers.

The PowerShell Alias Provider

We discussed what an Alias “is” in PowerShell tutorial 3. The Alias Provider enables access to all the aliases in PowerShell. To mount a PSDrive we use the “Set-Location” cmdlet. In this example, we want to mount the “Alias:” PSDrive. Don’t Forget the colon(:).

Set-Location Alias:<enter>
PowerShell Training Alias Provider Image

Set Alias Drive

Image 5.2

As shown in image 5.2, we are now connected to the “Alias:” PSDrive. Just a quick note, PSDrives are only available in the PowerShell environment. You would not able to access the “Alias:” drive from a legacy windows command shell.

Now that we are mapped to the Alias: PSDrive we can use the same cmdlets as working with files and folders.

Eample 1. View a list of all aliases.

Get-ChildItem<enter>
PowerShell Training gci

All Aliases

Image 5.2

Example 2. List the properties and methods.

Get-ChildItem | Get-Member<enter>
PowerShell Training Alias GM

Properties and Methods

Image 5.3

Example 3. Use the -Name parameter to list all Aliases that start with the letter “R”. PowerShell supports the use of wild cards(*) to filter the results.

Get-ChildItem -Name R*<enter>
PowerShell Training Alias Name Parameter

Name Parameter

Image 5.4

Example 4. Building on example 3; instead of using a parameter to filter results, let’s filter using the “name” property of the Alias object.

Get-ChildItem | Where-Object {$_.name -like “R*”}<enter>
PowerShell Training Alias Filter.

Where-Object Filter

Image 5.5

We have worked a lot with aliases in a previous tutorial, so I’m going to move along to the next Provider. Feel free to use the commands listed in the table (above) and experiment with the Alias Provider.

The PowerShell Environment Provider

You may already be familiar with what the Environment Providers is, it is equivalent to running the “set” command in a windows CMD command shell. It provides a listing of all the environment variable defined on the system. Graphically, you can view the environment variables by going to System Properties -> Advanced Tab -> Click the “Environment Variables” button.

PowerShell Training Evironment Variables

ENV Variables

Image 5.6

Example 1. List Environment Variables

  1. Get list of available PowerShell Providers.
    Get-PSDrive<enter>
  2. Map PSDrive to Environment Provider.
    Set-Location env:<enter>
  3. Get listing of Environment Variables.
    Get-ChildItem<enter>
PowerShell Training Get Environment Variable

List Variables

Image 5.7

Example 2. Obtain the value of an Environment Variable

  1. Output the value of the “OS” variable.
    Get-ChildItem OS<enter>
  2. Output all properties for the “OS” variable.
    Get-ChildItem OS | Format-List *<enter>

Example 3. Create a new Environment Variable

  1. Create a new variable using the “New-Item” cmdlet. Let’s call the new variable “MyVariable” and give it a value of “This is my new variable.” The Path argument will be a dot (.) meaning current location, which would be “env:”
    New-Item -Path . -Name MyVariable -Value “This is my new variable”<enter>
PowerShell Training New Environment Variable

Create Variable

Image 5.8

Use “Get-ChildItem” cmdlet to verify that the new variable exists.

Example 4. Renaming the Environment Variable

  1. Let’s rename the “MyVariable” variable to “MyRenVar.”
    Rename-Item -Path env:MyVariable -NewName MyRenVar<enter>
  2. Now use the “Get-ChildItem” cmdlet to verify the change.
    Get-ChildItem<enter>

Example 5. Removing the Environment Variable

  1. To remove the “MyRenVar” variable we us the “Remove-Item” cmdlet.
    Remove-Item MyRenVar<enter>
  2. Use “Get-ChildItem” to verify the variable has been removed.
    Get-ChildItem<enter>

PowerShell File System Provider

By default, the File System Provider is accessed when PowerShell is launched. The File System Provider allows you to create, retrieve, and remove files and folders. Also, the File System Provider allow you to modify files by either appending or overwritting data. This section of the PowerShell Providers tutorial explains how to do this.

Example 1. Listing Files and Directories

  1. Connect to the File System Provider. Close and re-launch PowerShell -or- connect to the File System Provider using the “Set-Location” cmdlet. Use the backslash (\) character to connect to the root of C: Drive
    Set-Location C:\<enter>
  2. List Files and Directories under the root of C: Drive.
    Get-ChildItem<enter>
  3. List Files and Directories including sub-direcories.
    Get-ChildItem -Recurse<enter>

If your file system is large, the command in step 3 may take awhile. Use “Ctrl + C” to stop processing commands in PowerShell, just like you did in CMD command shell.

What is the “Mode” column? 5 bits of information you need to know.

  • First entry is either “d” (indicates item is a directory) or “-” (indicates item is a file).
  • The last 4 entries present the properties of a File and/or Directory (a r h s). “a” = archive bit is set, “r” = read only, “h” = hidden, and “s” = system. A “-” in any of these entries means the bit is not set.
PowerShell Training Mode

Mode

Image 5.9

Note: By default, “Get-ChildItem” cmdlet or an Alias does not show hidden files and Directories. To show hidden files use the “-force” parameter.

Get-ChildItem -Force<enter>

As stated earlier in this PowerShell tutorial, Providers allow the use of the same cmdlets. Here is a second look at the cmdlet table, so that you don’t have to scroll back to the top.

Cmdlet Alias Cmd Commands Descritption
Get-Location gl pwd Current Directory.
Set-Location sl cd, chdir Change current directory.
Copy-Item cpi copy Copy Files.
Remove-Item ri del Removes a File or directory.
Move-Item mi move Move a file.
Rename-Item rni rn Rename a file.
New-Item ni n/a Creates a new empty file or folder.
Clear-Item cli n/a Clears the contents of a file.
Set-Item si n/a Set the contents of a file.
Mkdir n/a md Creates a new directory.
Get-Content gc type Sends contents of a file to the output stream.
Set-Content sc n/a Set the contents of a file.

Example 2. Using “Get-Location” Cmdlet

Use “Get-Location” to show current directory.

Get-Location<enter>

Using Alias and CMD Command.

gl<enter>
pwd<enter>

Example 3. Creating files and Directories

Use “New-Item” cmdlet to create a New Directory.

New-Item -Path C:\NewFolder -Type Directory<enter>

A cool thing about PoweShell, it will assist you when you leave out required information. For example, let’s say your creating the directory in the example above but you forget the -Type paramter.

New-Item -Path C:\NewFolder<enter>
PowerShell will prompt you for the missing parameter…
Type:

Continuing with the “New-Item” cmdlet, let’s create a file in our new directory.

New-Item -Path C:\NewFolder\NewFile.txt -Type File<enter>

Example 4. Move NewFile to the root of “C:\” using “Move-Item” cmdlet

Move-Item -Path C:\NewFolder\NewFile.txt C:\<enter>

Verify file moved.

Get-ChildItem N*<enter>

Example 5. Renaming Files and Directories

Let’s rename the NewFile.txt to RenFile.txt.

Rename-Item -Path C:\NewFile.txt RenFile.txt<enter>

Verify the file has been renamed.

Get-ChildItem R*<enter>

Rename Directroy NewFolder to RenFolder.

Rename-Item -Path C:\NewFolder RenFolder<enter>

Again, verify the change.

Get-ChildItem R*<enter>

Example 6. Removing Files and Directories

in our last example of this PowerShell training section, let’s remove the RenFolder and RenFile.txt. Just for fun, let’s add the -confirm parameter so that PowerShell prompts us to confirm the action.

Remove-Item -Path C:\RenFile.txt -Confirm<enter>

Press “Y” to confirm the deletion of the file and verify the files has been removed.

Get-ChildItem R*<enter>

You should still see the RenFolder but the RenFile is no longer present. Now remove the directory.

Remove-Item -Path C:\RenFolder -Confirm<enter>

Again, press “Y” to confirm and verify Directory has been removed.

Get-ChildItem R*<enter>

There are other cmdlets such as “Clear-Item” and “Set-Item” that enable you to work with data within files. Use “Get-Help” on these cmdlets to read about how to use these cmdlets in the PowerShell FileSystem Provider. I personally like to use “Get-Content” to output a files contents to the screen and “Set-Content” to add information to a file.

PowerShell Function Provider

PowerShell has a set of Functions specified in the PowerShell engine. The PowerShell Function Provider allows us to access these functions using, hope this is starting to sound redundant, the same cmdlets as working with Files and Folders.

Not familiar with what a function is? A function allows you to make calls to a block of code. When scripting, if you notice that you are using the same code over and over (within the same script), you should consider creating a function. A function would reduce the amount of code and keep your scripts clean and readable. The examples in the section will help define a Function. Be aware that we are discussing Functions defined in PowerShell, not how to create PowerShell Functions. Creating your own Functions comes later in the PowerShell Scripting tutorials.

Example 1. Listing Functions

  1. Use “Set-Location” cmdlet and connect to the PowerShell Function Provider’s PSDrive.
    Set-Location Function:<enter>
  2. You should be familiar with what cmdlet comes next…
    Get-ChildItem<enter>
PowerShell Training List Functions

Functions Provider

Image 5.10

Image 5.10 displays the Functions that are defined in PowerShell. “Name” is the name given to the function and the “Definition” is the code that runs when we call the name.

What does it mean to “call” a function? In PowerShell, we are only required to type a function name and the corresponding code will execute. For example, typing “set-Location C:” navigates to the root of C: drive. We can also navigate to the root of C: just by typing(calling) the “C:” function name. PowerShell runs the “Set-Location C:” code which places us at the root of C: drive. Let’s take a look at another example.

Example 2. Viewing the Code of a PowerShell Function

  1. We are going to use the “Get-Content” cmdlet to view the code block of the Clear-Host Function.
    Get-Content Clear-Host<enter>

    Output:

    $spaceType = [System.Management.Automation.Host.BufferCell]; $space = [Sys
    tem.Activator]::CreateInstance($spaceType); $space.Character = ‘ ‘; $space
    .ForegroundColor = $host.ui.rawui.ForegroundColor; $space.BackgroundColor
    = $host.ui.rawui.BackgroundColor; $rectType = [System.Management.Automatio
    n.Host.Rectangle]; $rect = [System.Activator]::CreateInstance($rectType);
    $rect.Top = $rect.Bottom = $rect.Right = $rect.Left = -1; $Host.UI.RawUI.S
    etBufferContents($rect, $space); $coordType = [System.Management.Automatio
    n.Host.Coordinates]; $origin = [System.Activator]::CreateInstance($coordTy
    pe); $Host.UI.RawUI.CursorPosition = $origin;

So my guess is that you would be more inclined to calling the “Clear-Host” function than actually typing the code required to clear the screen. Can you see how calling a function reduces the amount of code written in the script?

Before getting in too deep and making your head swim, I’m going to end this discussion about this Provider until we talk more about PowerShell Functions and Scripting. For now, let’s move on to the coolest PowerShell Provider in the world!!!

The PowerShell Registry Provider

If you ever wanted to work with the registry with the same ease as working with the file system, your wish has come true. The Registry Provider allows us to connect to two PSDrives; HKCU (HKEY_CURRENT_USER) and HKLM (HKEY_LOCAL_MACHINE). With the Registry Provider we can:

  • Navigate the registry.
  • Search the registry.
  • Create new registry keys.
  • Delete registry keys.
  • Add new values.
  • Modify existing values.
  • Manage ACLs (Access Control Lists).

Eample 1. Connect to the HKLM PSDrive and List Registry Keys.

  1. The two PSDrives we can connect to are HKLM and HKCU. Verify this by checking which PSDrives are available.
    Get-PSDrive<enter>


    Image 5.11

    PowerShell Training PSdrive

    Registry Provider

  2. Connect to HKLM PSProvider using the “Set-Location” cmdlet.
    Set-Location HKLM:<enter>
  3. We can also connect anywhere in the path. Let’s connect to the SOFTWARE Key:
    Set-Location HKLM:\Software<enter>
  4. From the Software location let’s list the keys available.
    Get-ChildItem<enter>

    Image 5.12

    PowerShell Tutorial - HKLM

    HKLM

We’re all familiar with the warnings of making changes to the Registry. Since I wish to only help and do no harm, I’m not going to provide examples of making registry changes. Just note that you can use the same cmdlets used when working with all PowerShell Providers.

Cmdlet Alias Cmd Commands Descritption
Get-Location gl pwd Current Directory.
Set-Location sl cd, chdir Change current directory.
Copy-Item cpi copy Copy Files.
Remove-Item ri del Removes a File or directory.
Move-Item mi move Move a file.
Rename-Item rni rn Rename a file.
New-Item ni n/a Creates a new empty file or folder.
Clear-Item cli n/a Clears the contents of a file.
Set-Item si n/a Set the contents of a file.
Mkdir n/a md Creates a new directory.
Get-Content gc type Sends contents of a file to the output stream.
Set-Content sc n/a Set the contents of a file.

I will show you one very cool example of using the “Get-ChildItem” cmdlet to list installed Hot Fixes on a system:

Get-ChildItem -Path “HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix”<enter>

Note: In the -Path parameter, quoting the path statement was required as there is a space between Windows and NT.

You should now see a list of “Hot Fixes” that have been installed on the system. Staying with the theme of this PowerShell tutorial, I’m going to use the “CD” alias to navigate to one of the “Hot Fix” keys. Choose any hot fix you wish to enumerate.

CD KB888240<enter>

Next question should be… How do we enumerate the information inside the registry key? Simply use the “Get-ItemProperty” cmdlet.

Get-ItemProperty .<enter>

I used the “.” as we are currently working within the registry path location. You can also get the properties using the -Path parameter. Here’s the example:

Get-ItemProperty -Path “HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix\KB888240″<enter>

Now we see all the properties, how about just a specific property?

Get-ItemProperty . -Name Comments<enter>

Create and Remove a New Registry Key and Property

First, Let’s work from the root of SOFTWARE.

Set-Location -Path HKLM:\SOFTWARE<enter>

Create new registry Key and Default Property using “New-Item” cmdlet from the table.

New-Item -Name Test -Value “This is a test string”<enter>

Verify “Test” key exists

Get-ChildItem T*<enter>

Verify the default property has the string value we created.

Get-ItemProperty -Path .\Test<enter>

Next, Let’s delete the new key using the “Remove-Item” cmdlet.

Remove-Item Test<enter>

Verify the key has been removed.

Get-ChildItem T*

Using the Registry Provider we are able to navigate, enumerate, create, and delete registry items just like files and folders.

Real-World Example: An associate of mine started working for a banking institution. We’re talking multiple locations around the United States. His boss didn’t like the naming convention for network printers as they provided no clue of printer type or location. His task was to create new print queues (with a new naming convention) and cut all the user over to the new print queues. Because he was dealing with multiple locations, it was impossible for a tech to be on-site to remap clients to the new print queues. Another requirement was to automate the process so that clients would not experience down time when printing. He told the boss… “No Problem.”

I’m only going to describe what he did in pseudo code as it would take another tutorial to examine his script. Network Print Queues are stored in the registry as a UNC (\\PrintServer\PrinterName). He created a second print queue for each printer on all his print servers. Created a printer script which used an array to store the old printer names and their new counterparts. The script would change the registry setting from \\PrintServer\OldQueue to \\PrintServer\NewQueue while also preserving the default printer setting. He replicated the new script to all Domain Controllers in his environment and edited the company’s logon script to call the printer script. When the printer script runs, it looks at the registry keys and if it finds reference to an old print queue name, it would edit that key with the new value. He allowed the script to run for a month or two to ensure that everyone using shared PCs would get the new print queues. After that time period, if he received calls from clients stating they could not connect to a new printer, he would just turn on the print script (uncomment it in the main logon script) and ask the client to re-logon the Domain.

This example shows just how powerful connecting the registry can be. Needless to say, his boss thought he was brilliant (which he is) an sent him off to Hawaii (ok – maybe not! But it is a nice thought).

The PowerShell Variable Provider

What is a variable? I like to think of a variable as a “little box” that is used to store information. The Variable Provider shows us which PowerShell and user defined variables are available. Again, we will be working with variables when scripting, so this is just an introduction.

Example 1. Connect to the PSDrive Variable: and Show a List of Available Variables

Connect to the PSDrive.

Set-Location Variable:<enter>

Use.. What Command to list variables?

Get-ChildItem<enter>

Example 2. List the Information in the PSHome Variable

In PowerShell, variables are preceded by the dollar sign character ($). However, the list of variables in example 1. don’t show a “$” sign. To view the information stored in the PSHome variable, just add the “$” before the variable name.

$PSHome<enter>

The $PSHome variable holds the information of the PowerShell installation path. Check out the information stored in other variables such as the $Profile and $Home variables.

Example 3. Create a User Defined Variable

There are a few ways to create variables. Since were talking about File System cmdlets used with providers, sticking with theme we would do the following:

New-Item MyVar -Value “This is my new variable.”<enter>

You can also use the “Set-Variable” cmdlet to accomplish the same:

Set-Variable MyVar2 -Value “This is my second variable.”<enter>

This last example is most commonly used when scripting. You will find yourself using this example more than the others:

$MyVar3 = “This is my third variable.”<enter>

Let’s sort the listing of variables by name and verify our newly created variables exist.

Get-ChildItem | Sort {$_.Name}<enter>

Do you see MyVar, MyVar2, and MyVar3 user-defined variables?

Example 4. Remove Variables

Let’s use the “Remove-Item” cmdlet to remove the variables we created:

Remove-Item MyVar,MyVar2,MyVar3<enter>

Let’s verify the variables have been removed:

Get-ChildItem | Sort {$_.Name}<enter>

By now your asking yourself, what is $_.Name? We can see that $_ must be a variable (all variables are noted by the dollar sign in PowerShell)… and it is. As defined, variables hold information. $_ is a special variable the holds the object piped from the “Get-ChildItem” cmdlet. The .Name is the Name Property of the object. I know your sick of me saying this but, we will explore script blocks in a later PowerShell tutorial.

One more PowerShell Provider to go…

The PowerShell Certificate Provider

Here is the last PowerShell Provider we need to cover. Using “Get-PSDrive” cmdlet we can see that we need to connect to the “cert” drive.

Example 1. Set Location to the Cert PSDrive and List all the Certificates on the System

Set-Location cert:<enter>
Get-ChildItem<enter>

This command truncates the “StoreNames” for good reason, there are a lot of entries. If you want a report of all certificates on a system may I suggest the following:

Get-ChildItem -Recurse | Export-CSV “C:\Certificates.csv”<enter>

View results:

Invoke-Item “C:\Certificates.csv”<enter>
PowerShell Training Certs

Certificates

Image 5.13

Wow!!! we made it to the end of this PowerShell Training session. The basic concepts to take away from this tutorial are that PowerShell Providers allow us to use common cmdlets outside of the PowerShell environment. We only have to learn a few cmdlets, shortening the learning curve, to be affective working with:

  • PowerShell Aliases
  • Environment Variables
  • Files and directories
  • Functions
  • The Registry
  • Variables in PowerShell
  • Certificates

Hope you enjoyed this tutorial, use the comment section for any questions or comments. See you in the next PowerShell Tutorial…

Email This Page To A Friend Email This Page To A Friend

Comments

great tuto, thanks for the hard work

By Prashant Khopkar on April 11th, 2008 at 3:00 am

Best read! Enjoyed the simplicity, each example can be tried and explored in number of ways!

There is no mkdir cmdlet…

Thanks for the great tutorials, much faster and more hands-on than scanning a book. I’m already seeing ways to use this at work.

Time for the next tutorial…

I’ve come back here from the Active Directory tutorial to see what the square brackets notation means. Apparently “[ADSI]…” means to use the ADSI provider. This works, but I don’t understand how! Also, how can I find out what providers are available? There are no commands with noun=provider.

By NetGuyDave on August 8th, 2008 at 10:44 am

Thanks for taking the time to put together such a simple to understand tutorial. And I really want to say thank you for not assuming I know VB Script. Other tutorials keep saying “do it just like in VBScript except…..”, which doesn’t help me at all.

Many thanks, Sir, I really get a lof from your tutorial.

Your tutorial is really fantastic. Really good examples

Keep up the good work !!

Excellent guide, thanks for all the hard work. I appreciate it.
Karl

Excellent Post, thanx for sharing the same.. Will keep on reading the post :D

Stumbled your post .. cheers

Great work. I’m learning a ton.

By Script Newbie on March 26th, 2009 at 11:05 am

Thank you for the great tutorial. I’m just new to this, so this might seem like a stupid question. In your above example with your associate who works for the bank, am I correct in assuming that all the client machines would have to have PS installed before they could run the logon script?

By KeithChan on April 1st, 2009 at 8:42 pm

Script Newbie, the purpose of the example above was to demonstrate the power of using scripts to modify the registry.

The registry changes above were probably carried out using a .vbs file which was called by the login script.

By David Rogers on May 26th, 2009 at 3:38 pm

Excellent tutorial series so far – If I had founbd this a year ago, I would have started using PowerShell a year ago!

In this tutorial, I think there is a CD step missing. before you do a “CD KB888240″m you would need: cd “HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix”

Thanks for this service!
David

I don’t understand why command Rename-Item failed:
#__Change directory name [ C:\PStests\A\BinA => C:\PStests\A\B ]
Set-Location C:\PStests
Rename-Item A\B* -newname B

# __It works correctly when virtual drive Ex: used (instead of C:) :

New-PSDrive -name Ex -PSProvider filesystem -root C:\PStests
Rename-Item Ex:A\B* -newname B

By powershell newbie on December 17th, 2009 at 4:49 pm

Awsome Tutorial! Thank You for taking the time. Please let me know if You decide to publish a book. I will be the first to buy.

Thanks for a great tutorial series!

I want to view the value of “hklm:\\SOFTWARE\Microsoft\Fusion\DisableCacheViewer”

I can do the following:

1. Get-ItemProperty “hklm:\\SOFTWARE\Microsoft\Fusion”
2. Visually look for the desired value (DisableCacheViewer)

Is there a way to directly query the value without listing them all out and having to manually look for it?

How would I change its value?

This is the best tutorial I have seen so far. Congratulations and thank you Jesse.

I have been following your guide from the beginning and haven’t have any issues. However, in this tuturial, when I type:
PS C:\MyScripts> get-content $PSHOME\about_Provider.help.txt, I get an error message:
Get-Content : Cannot find path ‘C:\Windows\SysWOW64\WindowsPowerShell\v1.0\about_Provider.help.txt’ because it does not ex
ist.
At line:1 char:12
+ get-content <<<< $PSHOME\about_Provider.help.txt
+ CategoryInfo : ObjectNotFound: (C:\Windows\SysW…ovider.help.txt:String) [Get-Content], ItemNotFoundExcep
tion
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand

My profile is on D: drive (D:\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1) and I am running 64-bit Windows 7 Ultimate.

Any suggesstion?

Thank you.

Zijo

Additional information:
1. I am running Powershell 2.0
2. about_…help.txt files are in different location: C:\Windows\SysWOW64\WindowsPowerShell\v1.0\en-US folder, instead C:\Windows\SysWOW64\WindowsPowerShell\v1.0
3. When I copy about_Providers.help.txt, it works OK (note: the file name in my case is about_Providers.help.txt instead of about_Provider.help.txt.

I think that may be the reason(s) for my issue. I don’t know if these difference will affect any commands (cmdlets) in the future tutorials?

Thank you.

Zijo

Just a brief correction of my item 3. I shoud have said:
3. When I copy about_Providers.help.txt from C:\Windows\SysWOW64\WindowsPowerShell\v1.0\en-US folder to C:\Windows\SysWOW64\WindowsPowerShell\v1.0
, it works OK (note: the file name in my case is about_Providers.help.txt instead of about_Provider.help.txt.)

Zijo

By Vishwas Setty on May 24th, 2010 at 8:27 am

i AM GETTING THIS ERROR WHEN TRYING TO CREATE A NEW REGISTRY KEY…PLZ HELP ME….

Set-Location : A parameter cannot be found that matches parameter name ‘NAME’.
At line:1 char:19
+ SET-LOCATION -NAME <<<< TEST-VALUE “TEST STRING”
+ CategoryInfo : InvalidArgument: (:) [Set-Location], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

By M Prindle on June 15th, 2010 at 7:58 am

This is a great tutorial series! To the others that are having issues when running under Windows7, for some of the exercises you may need to be running PS escalated as administrator. Win7 has extra security in place to stop the editing of the registry.

By Jeff Greenlee on August 4th, 2010 at 10:13 am

Hey.. great tutorial… one small thing I discovered regarding your Registry section. I think possibly the “hotfixes” structure for Windows 7 has changed. I was not able to locate it based on the given instructions (using “find” in regedit) any path using Hotfixes (although I did find a few Key values named “hotfix”.) Minor detail: and truthfully it doesn’t really matter.. (I just looked at other registry settings!)

Great series! Only one critique so far (and It’s a minor one!) :)

The file in the first instruction is named differently on my PC. It is about_providers.help.txt instead of about_provider.help.txt.

Is this a typo or does this file name differ from system to system?

This tutorial is exactly what I was looking for. Thanks so much for making it available. Just finished Tutorial 5, after doing 1-4 the past week, and am moving onward and upward.

In your tutorial, you mention: Get-Content $PSHOME\about_Provider.help.txt

On my system, I actually found it with this:
Get-Content $PSHOME\about_Providers.help.txt

First of all: Congrats on this great tutorial!

Now the issue: In Brazilian Portuguese language set, CSV uses semicolon as delimiter as long the comma is used as decimal separator.

Is there a way to replicate this behavoir in PowerShell?

TIA

One of the best read explaining concepts very nice.

By Bathrick3Rumble on March 12th, 2012 at 7:18 am

mulberry bayswater pouch chocolate
Moncler Lisbonne Down Jacket
mulberry daria hobo stone grey
mulberry small bayswater sactchel bag in oak
mulberry alexa clutch black
Moncler Cluny Jacket chocolate
Mulberry Scotchgrain Messenger Bag In Black Cognac
Mulberry Tony Briefcase In Oxblood
Mulberry Walter Printed Leather In Chocolate
mulberry daria hobo oak
Moncler Urville Hooded Jacket
mulberry mabel hobo oak
Mulberry Tony Briefcase In Oak
Moncler Mens Coats In Long Down Dark Blue
mulberry bayswater shining leather wine red

Youporn.com
http://www.mulberrysclassics.co.uk

Thank you for you nice tutorial! I am building a sharepoint farm and need to learn powershell. I have the job of creating 120 subsites based on information from a spreadsheet. Learning powershell has become a prerequisite for me, and this tutorial is extremely helpful. Thank you so much!

By Bob Hatcher on April 13th, 2012 at 12:56 pm

Great Tutorial. I am getting over the learning hump wit this web package of yours. I’m running Windows 7 Pro 32 bit and up to the registry portion no issues. I have no HotFix folder. I made one and then made a string with the KB888240. I can see it in regedit, but not through PS. Any ideas sir?

By Bob Hatcher on April 13th, 2012 at 2:11 pm

I started over with Providers and switched to an XP system (after loading Powershell) and was able to follow through on the registry lessons.

By Bob Hatcher on April 13th, 2012 at 2:12 pm

I switched over to an XP system and was able to follow through with the registry lesson.

You have expailed this in a better way, even a beginner can understand it very clearly…thanks a lot sir….

Thanks
Ajay

You should be writting books man! Great tutorials.

Interesting, and oh-so ‘power-packed!’

Excellent tutorial! Thanks

Great tutorials. I’m learning a lot. Thanks.

In my environment, UAC is enabled. Also, we log on to systems with a standard user account and use “runas” when administrative rights are needed.

Some commands like “Stop-Service” require admin rights.
Other commands like “New-Item” in the reqistry require UAC elevation.
I can’t figured out how to run powershell as an alternate user (runas) while also running with UAC elevation.

Any ideas?

Ok, never mind. I didn’t realize that my user account had local admin rights on my WS. Right-clicking and “Run as Administrator” didn’t give me the permissions that I needed.
After removing my account from the local admins group, “Run as Administrator” now prompts me for credentials. If needed, I can now run using domain admin credentials.

I am getting different results from the Registry functions. I can Set-Location to “HKLM:\SOFTWARE”, but when I get two columns (Name, Property) instead of the four you list. None of them are Microsoft (or any other company) callable functions, so the next function call, “HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix” fails because it can’t find the function. What am I doing wrong?

Hi
i am from Iran
Thanks a lot

Thank you for your great tutorials. I’m one of your students in Japan.

I have a question about hotfix.

My pc is running on Windows 7 64bit. I couldn’t find hotfix information at “HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix” It seems that the location has changed to “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall”

However, I cannot get the same result as what appwiz.cpl shows about KB.

Any suggestion is really appreciated.

Thanks again.

Thank you! This solved my problem with SQL Server 2012 executing Powershell with SQLSERVER as the provider. Using Set-Locaiton drive: fixes the issue.

When I create the test string value in the registry using New-Item this shows as existing under HKLM\software in PS, but when I check regedit the normal way, it is created under HKLM\Software\Classes.

Does anyone know why this is?

@Tom M

I think the answer to your question is the following:
in the command prompt or powershell type

runas /user:adminsitrator powershell.exe

is it normal for the Get-Content $PSHOME\about_Provider.help.txt command to fail? It returned
Get-Content : Cannot find path ‘C:\Windows\System32\WindowsPowerShell\v1.0\about_Provider.help.txt’ because it does not
exist.

I verified that the folders are there, but the file is not.

I want to be sure it’s not a sign that there’s a problem with my powershell.

I am running this command jbadmin@JXXXXXXX Software> Get-ChildItem -Path “HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix”

and then get this error message:

Get-ChildItem : Cannot find path ‘HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix’ because it
does not exist.
At line:1 char:1
+ Get-ChildItem -Path “HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\HotFix”
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (HKEY_LOCAL_MACH…tVersion\HotFix:String) [Get-ChildItem], ItemNotFound
Exception
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

I am running Windows 7 64 bit. Any idea why or what I am doing wrong?

 

Leave a Comment