DEV Community

Cover image for 5 PowerShell Modules You Should Know About
Jason Phillips
Jason Phillips

Posted on

5 PowerShell Modules You Should Know About

We all know the possibilities powershell can offer from automation, to cloud, to system administration.

The large variety of from modules have amplified powershell’s capability. Here are a few essential modules and a few light-weight examples of using them in action.

I. Import-Excel

Import-Excel is a powershell module that provides functions to generate excel workbooks. If you need something a little more advanced the “old csv file.” You can format, add pivots, and more

Import-Module "importexcel"

$path = ".\output-file.xlsx"
$excelfile = Export-Excel  $path -Passthru -AutoSize -WorksheetName "Worksheet 1"

$row=1

$ws.Cells["A$row"].value ="Subscription"
$ws.Cells["B$row"].value ="ResourceGroup"
$ws.Cells["C$row"].value = "PreTaxCost"
$ws.Cells["D$row"].value = "Currency"

# Fill the background-color
Set-ExcelRange -Worksheet $ws -Range $ws.Cells["B$row"] -BackgroundColor Cyan -Bold 
Set-ExcelRange -Worksheet $ws -Range $ws.Cells["C$row"] -BackgroundColor Cyan -Bold
Set-ExcelRange -Worksheet $ws -Range $ws.Cells["D$row"] -BackgroundColor Cyan -Bold 


$excelfile.Save()
$excelfile.Dispose()

II. addsadministration

addsadministration is ActiveDirectory Powershell module used to quickly commands to active directory like add users and groups. Honestly, I dont know how anyone could administer AD with out this powershell module. Unlike most module availabile on powershell gallery. You either need to running a windows server or install the RSAT

import-module aadsadministration

 New-ADUser -Name "ChewDavid" -OtherAttributes @{'title'="director";'mail'="chewdavid@fabrikam.com"}

III. AzSK

Azure Devops Security Kit (or better known by its module name as AzSK) offers plethora of tools and applications for securing your azure subscription resources from the subscription level, development, or ci/cd pipeline.

For example, to validate your arm template for any security vulnerabilities and validate it will meet compliance best-practices

Import-Module AzSK
Get-AzSKARMTemplateSecurityStatus –ARMTemplatePath <Path to ARM Template>  -UseBaselineControls

Alt Text

The result is the output of the arm template checker for an appservice arm template I was planning to deploy.

This is just the tip of iceberg. You can inspect your entire subscription or resource group with this powershell module as well.

IV. Universal Dashboard

Universal Dashboard is a website/webframework for powershell that allows teams to quickly develop websites, restful apis , dashboards all while leveraging a modern ui underneath the covers.

#simple hello-name example

install-module universaldashboard  -Scope CurrentUser
import-module universaldashboard

#lets output a simple request
$hellopage = New-UDPage -Url "/Hello/:name" -Endpoint {
    param($name)
    New-UDLayout -Columns 2 -Content {  
    New-UDCard -Id "DataCard"  -Content {

     New-UDMonitor -Title "Downloads per second" -Type Line -Endpoint {
     Get-Random -Minimum 0 -Maximum 10 | Out-UDMonitorData
        }
     }
    New-UDCard -Title "Hello $name" -Id "PageCard"
}
}

#add the page to the dashboard object
$dashboard = New-UDDashboard -Pages @($hellopage)

#Change the -port to anything; I'm using 1005
Start-UDDashboard -dashboard $dashboard -port 1005

After running powershell, if you go to http://localhost:1005/hello/name, you should get response back.

Its important to note their is a community (free) and enterprise version of this module use the Install-Module -Name UniversalDashboard.Community when installing

V. WriteAscii

Need a cool splash logo at the console. Checkout write ascii. Available in the PSGallery

Import-Module writeascii
"Hello World" | writeascii -foreground cyan

Alt Text

Conclusion

Hopefully, if you’re using PowerShell pretty consistently in your day I hope this post was hopeful; be it work or as a hobby. It’s worth mentioning that most of these gems are generated by the dedicate community of powershell users. Feel free to share your most useful powershell modules you use.

Top comments (0)