Getting Started with PowerShell

What is PowerShell?

PowerShell is a powerful, cross-platform scripting language developed by Microsoft and has been integrated into Windows since Windows 7. PowerShell can be used interactively (in a terminal) or by saving and running blocks of code (scripts). It has integrations with many Microsoft products, making it easy to get helpful output without much effort. PowerShell is used extensively within the IT Security and System Administration disciplines, but it can benefit almost all IT positions.

Opening PowerShell

If you are running Windows version 7 or newer, then a quick way to access Powershell is by right-clicking the Start menu and then clicking "Windows PowerShell" or "Terminal" (depending on the Windows version). This will open into the command line (shell), perfect for running cmdlets one at a time. When you are more comfortable and want to start writing scripts, you will instead want to open Windows PowerShell ISE (Integrated Scripting Environment). Searching for PowerShell in the Windows search bar will display both options and 32-bit (x86) versions.

Linux and Mac users must first install PowerShell from the PowerShell GitHub page:?https://aka.ms/powershell-release?tag=stable.

Running Cmdlets

PowerShell commands are called cmdlets (pronounced "command-lets"). Cmdlets are usually in the form of "Verb-Noun." For example, you can use the cmdlet?Get-ChildItem?to list all contents of your current directory. Parameters are additional parts of cmdlets that change how they work. For example, we can use the parameters -Path "C:\" and -Hidden to have?Get-ChildItem?show all hidden items in the C:\ directory. The cmdlet would look like?Get-ChildItem?-Path "C:\" -Hidden.?

Discovering What You Can Do

Three cmdlets will help you immensely throughout your time using PowerShell:?Get-Command,?Get-Help, and?Get-Member.


Get-Command?allows you to find new commands that you want to use.?

Working with Comma Separated Value (CSV) files? Use?Get-Command?-Noun CSV to see all the cmdlets that allow you to manipulate them.?

Do you want to start a service but need to know the exact cmdlet? Try?Get-Command?-Verb Start. The Windows PowerShell ISE has a built-in Command Explorer, which is more user-friendly, but I recommend trying?Get-Command. It gives you an excuse to experiment on the command line.


Get-Help?gives you information about a wide variety of PowerShell topics. Before using?Get-Help, open PowerShell as an administrator on your machine and run the cmdlet?Update-Help. Once you do, try running?Get-Help?-Name Get-ChildItem. You will see that we were scratching the surface of what the cmdlet?Get-ChildItem?can do. Even more information (in a friendlier format) is available if you run?Get-Help?-Name?Get-ChildItem?-Online. By adding the -Online parameter, you are taken to Microsoft's website with reference documentation, including examples and detailed descriptions of parameters.

Get-Member?helps you learn what you can do with objects. If you have a thing, "ABC," you could run?Get-Member?-InputObject "ABC." You will see that "ABC" is a System. String and many methods you can use to play with it.?

But wait, what is a Method? How do you use them? Get Help to the Rescue!

If you happened to run?Get-Help?-Name?Get-Help, you'll see in the description, "Conceptual help articles in PowerShell begin with about_." We could run?Get-Help?-Name about_Methods to understand what methods are and how to use them in PowerShell. You will find that 'To perform or "invoke" a method of an object, type a dot (.), the method name, and a set of parentheses "()." If the method has arguments, place the argument values inside the parentheses.' So looking back at the methods for Strings, we could try "ABC." ToLower() to convert the letters to lowercase.

Not Everything Works on the First Try

If you try running?Update-Help?in a PowerShell session that is not running as administrator, you will see?a lot?of red. What happened?

At the time of writing, the first line that appeared for me was "Update-Help: Failed to update Help for the module(s):" and then lists all of the PowerShell modules that were installed (which is quite a few by default). This means that updating the help could have been a lot better.

So what do you do from here? A few lines down, you might see: 'Access is denied […] start Windows PowerShell by using the "Run as Administrator" command, and try rerunning Update-Help.'

When using PowerShell, not all error output will be this helpful. But it will always give you an excellent place to start. Don't be discouraged when things don't work as expected. More than likely, the issue that you are running into is common. Looking up errors in a search engine like DuckDuckGo or Google will almost always yield helpful results quickly.

Where Do I Go From Here?

Everyone learns differently, so here are a few suggestions for free, high-quality resources that you can use to learn PowerShell.

I suggest Mike F. Robbins's book?PowerShell 101?for people who like reading. The book is made available for free on Microsoft's Website here (navigation is on the left):

https://learn.microsoft.com/en-us/powershell/scripting/learn/ps101/00-introduction

If you prefer to watch videos, John Savill released a great set of videos on YouTube:

https://www.youtube.com/playlist?list=PLlVtbbG169nFq_hR7FcMYg32xsSAObuq8

For people who want guided practice, try vexx32's PSKoans GitHub project:

https://github.com/vexx32/PSKoans

If these resources don't do it for you, Warren F created a complete list of resources here:

https://ramblingcookiemonster.github.io/Pages/PowerShellResources/index.html

Check out the arthur of this article - Glen Banks

要查看或添加评论,请登录

Tyrrell Brewster的更多文章

  • Hacking the Hiring Process: The Art of the Cybersecurity Analyst Resume

    Hacking the Hiring Process: The Art of the Cybersecurity Analyst Resume

    In the world of cybersecurity, your resume secures your path to success. As a cybersecurity analyst, your resume must…

  • Benefits of an Active Directory Homelab

    Benefits of an Active Directory Homelab

    This article delves into Homelabs – a hands-on playground that can completely change your IT career. Whether you're an…

    3 条评论
  • Every Security Analyst Should Do This | Capture the Flags (CTFs) Benefits

    Every Security Analyst Should Do This | Capture the Flags (CTFs) Benefits

    In the ever-evolving cybersecurity landscape, one of the most exhilarating and rewarding ways to hone your skills and…

    1 条评论
  • What is an IDPS?

    What is an IDPS?

    Security threats are becoming more sophisticated and harder to detect. To keep networks and systems secure, security…

  • What is a SIEM?

    What is a SIEM?

    In the world of cybersecurity, keeping track of a company's network activity is incredibly important to detect…

    2 条评论
  • What is a SOC?

    What is a SOC?

    As the world becomes more digital, security concerns begin to come to the forefront of many businesses' minds. Many…

    1 条评论
  • Cloud Resume Challenge [Part 2]

    Cloud Resume Challenge [Part 2]

    Hello everyone! I know I’m late, but I had a good reason, the cloud resume challenge is challenging. I was not prepared…

  • Cloud Resume Challenge [Part 1]

    Cloud Resume Challenge [Part 1]

    Whenever I really like a class that I've taken at WGU I made it a habit to come up with a project that corresponds with…

社区洞察

其他会员也浏览了