Create an Advanced Module
Knowing how to use Windows PowerShell is an important skill for efficient systems administrators. This IT Pro Challenge virtual lab will teach you how to create advanced PowerShell modules with custom functions. These modules help automate repetitive tasks. After completing this lab, you will feel confident in creating robust modules in PowerShe...
Windows PowerShell is a task-based command-line shell and scripting language. PowerShell is different from the normal command prompt, because PowerShell uses different commands, called cmdlets, and was designed specifically for system administrators. To be efficient as a Windows system administrator, you will need to know how to create a custom module on Windows and how to write and run modules in the Windows PowerShell.
PowerShell provides system administrators a tool for enhancing built-in PowerShell functions using PowerShell modules. A PowerShell module is an executable piece of PowerShell code that executes several cmdlets in sequence. Modules are particularly useful for sequences of commands that need to be run often, automating many of a system administrators’ daily tasks. PowerShell modules are highly-customizable and offer many tools for creating advanced modules.
To make the best use of PowerShell modules, you will need to know the advanced features. PowerShell offers and how to make modules more robust and reusable. This virtual lab will help you understand functions in PowerShell and how to create advanced PowerShell modules.
Understand the scenario: You are a system administrator for your organization. You have a function named Get-UpTime. You need to make your function more flexible.
Understand the environment: You are using an Azure resource group that contains an Azure virtual machine.
Configure your environment:
To begin this virtual lab, you will first prepare your resources. You will:
- Sign in to the Azure portal using given credentials.
- Connect to an Azure virtual machine (VM).
- Launch the Windows PowerShell.
Create a basic module:
Next, you will create your basic module. You will:
- Copy and paste a PowerShell function into Windows PowerShell ISE.
- Create a module manifest for your function.
- Customize the module manifest.
- Verify that the new function works appropriately.
Adding pipeline input support:
In this step, you will start to customize your module. You will:
- Add pipeline input support to the function.
- Remove the module from memory.
- Verify the pipelined input works appropriately.
- Test several uses of the function.
Add custom formatting to a module:
For the final step of this hands-on lab, you will add custom formatting to your function’s output. You will:
- Add a custom object type to the function’s output.
- Create a custom output file format for the function’s output.
- Update the module manifest to accept this output file format.
PowerShell modules allow users to execute complex tasks easily through programmed sequences of PowerShell commands. PowerShell modules can be used to create custom commands that can be executed in PowerShell. Several tools exist to enhance the PowerShell module's capabilities, and it is possible to create advanced modules. Advanced modules allow you to customize modules and make them more robust and flexible. Knowing how to create modules will automate many of the daily tasks required for systems administrators, saving time and energy. This virtual lab will give you real-world experience creating and executing advanced PowerShell modules.
In the “Create an Advanced Module” virtual lab, you will accomplish the following:
- Connect to a Windows virtual machine hosted in Azure.
- Create a PowerShell function.
- Create a PowerShell module manifest.
- Add pipelined input support to a function.
- Create a custom file format for the output of a function.
The Enable Advanced Data Security with Azure SQL Database virtual lab, an IT Pro Challenge, ...
This “Getting Started with Advanced PowerShell” IT Pro Challenge virtual lab teaches learners to create ...