Modules

A module is a self-contained reusable unit that can contain cmdlets, providers, functions, variables, and other types of resources that can be imported as a single unit to PS. It extends the functionality of powershell aside of the cmdlet it comes with. Some examples of modules are exchange online, ms graphs and ones that assist with updating lenovo devices and windows updates.


# Use the $PSModuleAutoloadingPreference variable to enable, disable and configure automatic loading of modules. 

$PSModuleAutoloadingPreference

# shows the path of modules that can be retrieved for powershell and downloaded to. Use ().split(';') to make it readable

$($env:PSModulePath).split(';') 

# Get Module with get-module. Modules for management/security/utility etc... Bitlocker, network ,etc..

Get-Module

# Reveal all modules in each folder (c:\Program files, C:\users\, C:\windows\system32)

get-module -ListAvailable 

# Import module to use. The module name will be scheduled tasks. It will show if [Get-Module] is triggered.
# 'Force' parameters will import again with latest function.

Import-Module -Name ScheduledTasks -Force

# View commands for the imported module.

Get-command -Module ScheduledTasks
Get-ScheduledTask

# Remove a module

Remove-Module ScheduledTasks

#Finding additional modules online depending on the workload. Find-Module will grab from PSgallery repository. Once its installed, import the module to use the cmdlets and functions it comes with.

Find-module -name AzureAD
Install-module -Name AzureAD
Import-Module -Name AzureAD

Get-Module

# To Uninstall modules, remove the loaded modules first then uninstall with admin rights. Close any apps using the module

Remove-Module AzureAD
Uninstall-Module AzureAD

Leave a comment