PowerShell Provider CMDlets -1
Full-Access Members Only
Sorry, this lesson is only available to Server Academy Full-Access members. Become a Full-Access member now and get instant access to this and many more premium courses. Click the button below and get instant access now.
Instructions
Q&A (0)
Notes (0)
Resources (0)
Saving Progress...
Resources
There are no resources for this lesson.
Notes can be saved and accessed anywhere in the course. They also double as bookmarks so you can quickly review important lesson material.
In this lecture we will take a look at several different cmdlets that are designed for use with Powershell Providers.
If you would like a complete list of provider cmdlets and links for further information, check the following link: PowerShell Provider cmdlets
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.
Set-Location
You can use this cmdlet to access PowerShell drives. This cmdlet changes the current location to a new location. The location could be a registry location, folder or subfolder. To understand how this works type:
Server Academy Members Only
Sorry, this lesson is only available to Server Academy Full Access members. Become a Full-Access Member now and you’ll get instant access to all of our courses.
Is there a download that should be included here?
Hi Chris Coleman
The cmdlets Robert is referring to are the commands that are on the Instructions transcript section. We have updated the lesson transcript to reflect these changes since in the past we had the lesson in PDF.
Ricardo