PowerShell for Pentesters Part 4: Modules with PowerShell

Introduction

The more we advance in our lab series, the more we notice the power of PowerShell. And it will only  become more noticeable.

In this lab we will discover how to manipulate modules with PowerShell. This is a very interesting and important part of learning PowerShell for us, because it will help us a lot in automating many tasks and operations.  

Modules  with PowerShell

As we have seen in the previous articles, modules represent a very powerful concept on PowerShell. Now we will not learn how to use them (we saw this before), but how to create and exploit them for our pentesting purposes, especially for automating routine tasks.

First, let’s remember the definition of a module. Microsoft describe modules as the following:

“A module is a package that contains PowerShell commands, such as cmdlets, providers, functions, workflows, variables, and aliases.

“People who write commands can use modules to organize their commands and share them with others. People who receive modules can add the commands in the modules to their PowerShell sessions and use them just like the built-in commands.” (Source)

We can get the list of available modules by using the Get-Module command:

 Figure 1: Get the list of available modules on PowerShell

The Get-Module command helps us get the modules that have been imported into the current session. And in our example, we used this command with the -ListAvailable option to retrieve the modules that are installed on the computer and can be imported in our session. Adding the option     -All makes us able to get all exported files for all available modules in our current session.

We can also import a module very simply by using the Import-Module command:

 Figure 2: Import module on PowerShell

And then we can remove it (Read more...)

*** This is a Security Bloggers Network syndicated blog from InfoSec Resources authored by Kondah Hamza. Read the original post at: http://feedproxy.google.com/~r/infosecResources/~3/M55tC_RAIfA/