Video: Learning PowerShell for the IT Administrator – Increase efficiency and automation
Video: Learning PowerShell for the IT Administrator – Increase efficiency and automation
For IT administrators who are hesitant to learn PowerShell, this post will help take the fear out of getting started.
PowerShell is not a scripting language. Yes, it does have a scripting language, but that’s for automation and to make tools, which we’ll discuss later.
PowerShell’s primary focus is to be a real-time interactive command tool that allows the user to be much more efficient in managing all system resources – whether it be users, servers, applications, deployments and more.
Many UNIX or Linux admins are already using PowerShell with ease, but if you haven’t tried PowerShell yet, let’s start off with a few basics.
At first glance, many newcomers to PowerShell get lost when they see the command line.
If you’ve worked with the older, or native, command prompt, you know that some commands are pretty familiar, and you’ve probably used them for a long time. Well, PowerShell has its own custom commands known as cmdlets, and they’re in what’s called a verb/noun pair.
Take a look at my current directory listing.
If you’re at that native command prompt, and want to change back to the root of C, you’d probably type “CD\”. PowerShell has a cmdlet for that called Set Location.
The result is changed to the root C:\.
If you wanted a directory listing you might type “dir”. PowerShell has a cmdlet for that called Get ChildItem.
If you wanted to clear the screen you could type “CLS” but PowerShell has its own cmdlet for that called Clear Host.
These special cmdlets may cause newcomers to fear PowerShell. It looks like there’s this whole new command structure to learn. Well, the creators of PowerShell made the command lines friendly for everyone.
If you want to change from your current directory back to the root, typing “cd\” works as well.
If you want to get a directory listing, type “dir”.
If you want to clear the screen, type “CLS”.
Interestingly, how do you get a directory listing in UNIX? Type “ls”.
You might remember from the old DOS days that if you wanted help, you could type “help”.
That gets you help for PowerShell as well. For those who work with UNIX or Linux, typing “man” provides help, too.
PowerShell provides flexibility for Windows administrators who are familiar with the native command line and for UNIX administrators who are familiar with their shell.
They can begin working right away, and so can you.
The best way to get started with PowerShell isn’t by opening up the command prompt. It’s by opening up the PowerShell prompt and doing what you would normally attempt to do.
Let’s see a couple other examples. At a command prompt you might need to check your IP addresses so you type “IP config”.
PowerShell will let you run Windows native commands as well. You can even run “ping”.
Let’s launch notepad.
Your regular Windows native commands will work just fine. How about MS Paint?
MS Paint launches as well.
You can now start using PowerShell right away for what you usually would do at the command line.
PowerShell enables you to run your native Windows commands as you begin to learn PowerShell cmdlets and start to write your own scripts to become a better administrator.
For an in-depth demonstration of using PowerShell in Active Directory see What is PowerShell and how can it make your IT staff more efficient?
Using the PowerShell Editor for customizing scripts:
The PowerShell editor is simply one liner commands that you would have typed at the console. The difference is there’s more structure around it, and the editor allows you to create your own cmdlets.
You can create custom cmdlets and put them in a module to use whenever you want. For example, I’ve created a couple cmdlets and put them in “JasonMod.psm1”.
These cmdlets are “Get-CompInfo”, which retrieves basic computer information, and “Set VolLabel”, which changes the labels.
We’ll run the cmdlet Get-CompInfo.
By default, this simple cmdlet returns basic computer information about our local host. As you can see, it gives us the computer name, local host, etc. Notice there’s no drive label on the hard drive, “drive C”, and that’s actually what we’ll fix next.
This cmdlet was written in a few minutes to collect some information, but the benefit of PowerShell is that when you make a cmdlet, you get many usable features. As simple as this cmdlet appears, it can also get information from any remote server. So let’s get information from server 1 and server 2.
Notice they don’t have “drive” labels either? Let’s fix this.
Now we’ll run the Set-VolLabel cmdlet. Starting with the Get-CompInfo cmdlet, using the parameters server 1 and server 2, we’ll now change it with the cmdlet that I made called Set-VolLabel and give it a new label of “drive C”.
With PowerShell, no news is good news, meaning we didn’t experience any errors. We can check the results to be sure by moving back and removing the portion of the pipeline and striking enter.
As you can see, the drive labels on the remote computers are now set.
You can start to see the power in PowerShell. It empowers you to use cmdlets to solve problems and to do IT administration tasks much more efficiently – and it also empowers you to easily create automation.
There is a learning curve to working with cmdlets, but once you get comfortable with them, you’ll start using PowerShell with all Microsoft products deployed in your organization. When Windows 8 releases, you’ll be able to use PowerShell to manage your environment efficiently and effectively.
As an IT admin, there’s no need to be afraid of PowerShell. You can start experimenting with PowerShell today, and I don’t think you’ll regret it.
Enjoy!
Knowledge is PowerShell,
Jason Helmick
Director of PowerShell Technologies
Interface Technical Training
You May Also Like
Active Directory, AD, cmdlet, cmdlets, command-line, Get AD user, Powershell, What is PowerShell, Windows PowerShell
A Simple Introduction to Cisco CML2
0 3698 0Mark Jacob, Cisco Instructor, presents an introduction to Cisco Modeling Labs 2.0 or CML2.0, an upgrade to Cisco’s VIRL Personal Edition. Mark demonstrates Terminal Emulator access to console, as well as console access from within the CML2.0 product. Hello, I’m Mark Jacob, a Cisco Instructor and Network Instructor at Interface Technical Training. I’ve been using … Continue reading A Simple Introduction to Cisco CML2
Configuring Windows Mobility Center and How to Turn it On and Off
1 1411 1Video transcription Steve Fullmer: In our Windows training courses, we often share information about the Windows 8.1 Mobility Center. Mobility Center was introduced for mobile and laptop devices in Windows 7. It’s present and somewhat enhanced in Windows 8. Since we don’t have mobile devices in our classrooms, I decided to take a little bit … Continue reading Configuring Windows Mobility Center and How to Turn it On and Off
OSPF Adjacency Troubleshooting Solution – Getting Close to the OSPF adj
0 247 1In this video, Cisco CCNA & CCNP instructor Mark Jacob shows how to troubleshoot OSPF Adjacency issues by showing the distance between routers with the show ip ospf neighbor command.
See what people are saying...