PowerShell Provider CMDlets -1
Server Academy Members Only
Sorry, this lesson is only available to Server Academy Full Access members. Upgrade your plan to get instant access to this and many more premium courses. Click the Upgrade Plan button below to get started.

Saving Progress...
In this lecture we will take a look at several different cmdlets that are designed for use with Powershell Providers. If you want to follow along you will need to download the lesson that came with this lecture. We will be copying and pasting commands into PowerShell.
If you would like a complete list of provider cmdlets and links for further information, download the document called PSProvider cmdlet links.pdf.
Location Cmdlets – These cmdlets are used for directory navigation. The cd (change directory) command can be used to navigate between directories. But, as the number of directories that we need to track grows, this approach becomes more and more inefficient, as most of these paths are usually too long to type. And that’s why location cmdlets can be extremely useful.
Get-Location – (alias GL) This cmdlet gets an object that represents the current directory.
Sets the working location to a specified location
Set-Location – (alias is SL) Sets the working location to a specified location. That location could be a directory, a subdirectory, a registry location, or any provider path.
Push-Location – (alias is pushd) Adds ("pushes") the current location onto a location stack.
Pop-Location – (alias is popd) Changes the current location to the location most recently pushed onto the stack by using the Push-Location cmdlet.
What is a stack? Think of a stack like a stack of books.

1984
Guliver’s Travels
Hamlet
Moby Dick
I add books by adding them to the top of the stack. If I want to remove a book, let’s say Guliver’s Travels, normally I would remove the first book, then remove the second book. In computer terms this is referred to “Last in, first out” or (LIFO)
So my book stack has two methods, add and remove. So, in computer terms a stack has two methods push and pop. An item is pushed to the stack (added) or popped off (removed) from the stack.
I can demonstrate this by creating 4 folders.
Let’s say that we need to work with these four folders.

From your C: drive create a folder called books, then create the four sub-folders. Stop the video while you do this.

Now lets add all four folders to the stack by using our pushd alias cmdlet
Type pushd c:\books\1984 (pressh return)
Type pushd c:\books\gulivers_travels
Type pushd c:\books\hamlet
Type pushd c:\books\moby_dick

Now let’s view the stack by using the get-location -stack (parameter)
remember (LIFO) last in first out
Type get-location -stack (press return)
Because get-location displays our current location, moby_dick is in the stack but not shown in the stack.
Now from PS C:\books\moby_dick location type popd
Type get-location -stack (moby_dick) has been removed from the stack)
From PS C:\books\Hamlet location type popd
Type get-location -stack now hamlet has been removed from the stack
From PS C:\books\Gulivers_Travels location type popd
Type get-location -stack (gulivers travels has been removed from the stack)
From PS C:\books\1984 location type popd
Type get-location -stack (1984 has been removed from the stack)
Type get-location -stack and now the stack is empty.
As you can see we can move between these four folders and easily remove the folders from the stack that are no longer needed.
Server Academy Members Only
Want to access this lesson? Just sign up for a free Server Academy account and you'll be on your way. Already have an account? Click the Sign Up Free button to get started..