PowerShell

Getting Started with PowerShell: A Beginner’s Guide for IT Apprentices

As an IT apprentice, mastering PowerShell is essential for automating tasks, managing systems, and boosting your productivity. In this beginner’s guide to PowerShell for IT apprentices, we’ll cover the basics, explore its advantages over Command Prompt, and walk through simple scripting examples to kickstart your PowerShell journey.

PowerShell fired out of a tank

Getting Started with PowerShell: A Beginner’s Guide for IT Apprentices

What is PowerShell? PowerShell is an object-oriented, interactive command-line shell and scripting language built on the .NET framework. It provides a comprehensive set of tools and utilities for automating tasks, managing configurations, and interacting with various systems and services, including Windows, Azure, and Office 365.

Advantages of PowerShell over Command Prompt:

  1. The use of Object-Based Scripting: Unlike Command Prompt, which operates with text, PowerShell works with .NET objects, allowing you to manipulate and control system components in a more sophisticated and flexible way.
  2. A much more Comprehensive Scripting Environment: PowerShell includes a scripting language that’s more advanced than the batch language used in Command Prompt. It supports complex functions, structured error handling, and advanced workflow capabilities.
  3. Integrated Scripting Environment (ISE): PowerShell ISE provides a graphical user interface with script editing, debugging, and execution facilities, which are not available in the traditional Command Prompt. Visual Code also offers support for PowerShell so ISE is not needed if you use that.
  4. Extensibility: Users can extend PowerShell’s functionality by writing their own cmdlets and modules or by using those created by others.

Basics of PowerShell:

  1. Cmdlets are the native commands used in the PowerShell environment. They follow a verb-noun naming convention, like Get-Help, Copy-Item, etc. Each cmdlet can be customized with various parameters to perform its task.
  2. PowerShell is similar to Command Prompt but leverages more powerful cmdlets.
    For instance, Get-ChildItem lists items in a directory, similar to dir in Command Prompt, but with more detailed output and options.

Methods to Launch PowerShell on Windows 10/11

Option 1) Call Powershell by typing “powershell” into a command line window

Option 2)
Step 1. Right click the Start Menu Icon (bottom left corner of the screen

Step 2. After right clicking, from the list select Windows PowerShell

Alternatively, search for powershell, in the windows search menu. You could also Run powershel like so

Having the Tool pinned to your Task Bar is quite useful, highty recommend that too. Having both CMD and PowerShell pinned at the same time could be considered pointless. As you can alwayss move been each of these languages from the same window:

5 PowerShell Commands Every IT Apprentice Should Know

As an IT apprentice, mastering PowerShell is crucial for managing systems efficiently. Here are five powerful PowerShell commands that will elevate your scripting game:

  1. Get-Help: Your Best Friend in Learning PowerShell
    • Syntax: Get-Help [cmdlet-name]
    • The Get-Help command is your go-to resource for understanding PowerShell cmdlets and their usage.
    • Example: Get-Help Get-ChildItem provides detailed information about the Get-ChildItem cmdlet.
  2. Invoke-Command: Running Commands Remotely with Ease
    • Syntax: Invoke-Command -ComputerName [computer-name] -ScriptBlock {[command]}
    • Invoke-Command allows you to execute commands on remote computers, saving you time and effort.
    • Example: Invoke-Command -ComputerName Server01 -ScriptBlock {Get-Service} retrieves the list of services running on the remote computer “Server01”.
  3. Restart-Computer: Rebooting Machines Remotely
    • Syntax: Restart-Computer -ComputerName [computer-name]
    • The Restart-Computer cmdlet enables you to reboot remote computers without physically accessing them.
    • Example: Restart-Computer -ComputerName Server02 restarts the computer named “Server02”.
  4. Enter-PSSession: Interactive Remote PowerShell Sessions
    • Syntax: Enter-PSSession -ComputerName [computer-name]
    • Enter-PSSession establishes an interactive PowerShell session with a remote computer, allowing you to run commands as if you were locally connected.
    • Example: Enter-PSSession -ComputerName Server03 starts an interactive session with “Server03”.
  5. Get-ChildItem: Exploring Files and Directories
    • Syntax: Get-ChildItem -Path [path]
    • Get-ChildItem is the PowerShell equivalent of the dir command, used for listing files and directories.
    • Example: Get-ChildItem -Path C:\Scripts lists all files and subdirectories in the “C:\Scripts” directory.

Master these five PowerShell commands,and you’ll be getting be more prepared to tackle a variaty of system administration tasks just remember to explore the Get-Help command to understand what you can do… unlock the full potential of each cmdlet and expand your PowerShell knowledge.

Simple Scripting Examples: (see more posts for scripts!)

  1. Creating a Folder and Moving Files




# Creates a new directory
New-Item -Path 'C:\MyFolder' -ItemType Directory

# Moves all text files from one directory to another
Get-ChildItem -Path 'C:\OldFolder\*.txt' | Move-Item -Destination 'C:\MyFolder'

2. Checking Disk Usage

# Displays disk usage
Get-PSDrive C | Select-Object Used, Free

3. Fetching System Information

# Fetches system information
Get-ComputerInfo | Select-Object CsModel, CsManufacturer, WindowsProductName

Starting with PowerShell can greatly enhance your productivity and capabilities in system management and automation. As an IT apprentice, investing time in learning PowerShell will be invaluable for your career growth.

To deepen your understanding, regularly practice with real-world tasks, utilize the vast resources available online, and consider joining a community or forum to exchange knowledge such as powershell.org

If you already know some batch or standard cmd commands for windows, why not learn the equivelent in powershell?

With practice and persistence, you’ll soon become proficient in leveraging PowerShell for automating tasks and managing systems efficiently.

Information Technology Support Analyst with over seven years of experience (in the telecommunications and manufacturing industries) ranging from user support to administering and maintaining core IT systems.

Related Posts

Learn Message Trace commands today and save time by searching efficiently

Efficiently Trace Messages in Exchange

In this guide, I’m diving into the most efficient ways to scan any exchange mail servers for information using “Message Trace” to trace messages in Exchange (On-Prem), Exchange Online (Office 365). I hope this will help you obtain useful information...