Modules

To check if a module is installed on your system,

 Get-Module [module name] -list | Select-Object Name,Version,Path

Module Types

Binary

Manifest

Script

Microsoft.PowerShell.Core

Get-Command

To list all commands of a module,

Get-Command -Module [module name]

Microsoft.PowerShell.Utility

Export-Csv

PS C:\> Get-Process | Export-Csv Processes.csv

Import-Csv

PS C:\> Get-Process | Export-Csv Processes.csv
PS C:\> $P = Import-Csv Processes.csv

Microsoft.PowerShell.Management

Join-Path

Best Examples of Join-Path in PowerShell

PackageManagement module

Commands

Find-Package            
Find-PackageProvider    
Get-Package             
Get-PackageProvider     
Get-PackageSource       
Import-PackageProvider  
Install-Package         
Install-PackageProvider 
Register-PackageSource  
Save-Package            
Set-PackageSource       
Uninstall-Package       
Unregister-PackageSource

Find-PackageProvider



PowerShellGet

PowerShellGet is the Package Manager for PowerShell.

Require: Windows Management Framework 5.1

To update from version 1 to version 2,

PS> Install-Module -Name PowerShellGet -Force

With the latest PowerShellGet module, you can:

  • Search through items in the Gallery with Find-Module and Find-Script
  • Save items to your system from the Gallery with Save-Module and Save-Script
  • Install items from the Gallery with Install-Module and Install-Script
  • Upload items to the Gallery with Publish-Module and Publish-Script
  • Add your own custom repository with Register-PSRepository

PowerShellGet - GitHub

Commands

Find-Command           
Find-DscResource       
Find-Module            
Find-RoleCapability    
Find-Script            
Get-InstalledModule    
Get-InstalledScript    
Get-PSRepository       
Install-Module         
Install-Script         
New-ScriptFileInfo     
Publish-Module         
Publish-Script         
Register-PSRepository  
Save-Module            
Save-Script            
Set-PSRepository       
Test-ScriptFileInfo    
Uninstall-Module       
Uninstall-Script       
Unregister-PSRepository
Update-Module          
Update-ModuleManifest  
Update-Script
Update-ScriptFileInfo

Find-Command

Finds PowerShell commands in modules.

Find-DscResource

Finds a DSC resource.

Find-Module

Finds modules from an online gallery that match specified criteria.

Find-Module dbatools | Save-Module -Path c:\PS

Find-RoleCapability

Finds role capabilities in modules.

Find-Script

Finds a script.

Get-InstalledModule

Gets installed modules on a computer.

Get-InstalledScript

Gets an installed script.

Get-PSRepository

Gets PowerShell repositories.

Install-Module

Downloads one or more modules from an online gallery, and installs them on the local computer.

Install-Module
       [-Name] <String[]>
       [-MinimumVersion <Version>]
       [-MaximumVersion <Version>]
       [-RequiredVersion <Version>]
       [-Repository <String[]>]
       [-Credential <PSCredential>]
       [-Scope <String>]
       [-Proxy <Uri>]
       [-ProxyCredential <PSCredential>]
       [-AllowClobber]
       [-SkipPublisherCheck]
       [-Force]
       [-WhatIf]
       [-Confirm]
       [<CommonParameters>]

Install-Script

Installs a script.

New-ScriptFileInfo

Creates a script file with metadata.

Publish-Module

Publishes a specified module from the local computer to an online gallery.

Publish-Script

Publishes a script from the local computer to an online gallery.

Register-PSRepository

Registers a PowerShell repository.

Save-Module

Saves a module locally without installing it.

Find-Module dbatools | Save-Module -Path c:\PS

Save-Script

Saves a script.

Set-PSRepository

Sets values for a registered repository.

Test-ScriptFileInfo

Validates a comment block for a script.

Uninstall-Module

Uninstalls a module.

Uninstall-Script

Uninstalls a script file.

Unregister-PSRepository

Unregisters a repository.

Update-Module

Downloads and installs the newest version of specified modules from an online gallery to the local computer.

Update-ModuleManifest

Updates a module manifest file.

Update-Script

Updates a script.

Update-ScriptFileInfo

Updates information for a script.

Install-Module

To install a module,

Install-Module [module name]

To install an unsigned module

Install-Module [module name] -SkipPublisherCheck

To install a module and allow the module to override or _clobber _an existing command already available from other modules

Install-Module [module name] -AllowClobber

Why do we need-AllowClobber?

Update-Module

To update a module

Update-Module -Name [module name]

To update all installed modules

Update-Module

View what would occur if Update-Module runs

Update-Module -WhatIf

Update a module to a specified version

Update-Module -Name [module name] -RequiredVersion [version]

Get-Module

To obtain a listing of all modules that are available on the system but are not loaded

Get-Module –ListAvailable

Microsoft.PowerShell.Utility

Out-File

Out-GridView (ogv)

PowerShell version < 6

Creating a GUI Using Out-GridView in PowerShell

Fun with PowerShell's Out-GridView

Out-Printer

Out-String

Microsoft.PowerShell.Security

PowerShell Community Extensions (PSCX)

Utility Modules

PowerShellHumanizer

https://www.powershellgallery.com/packages/PowerShellHumanizer/

To install,

Install-Module -Name PowerShellHumanizer

SQL Server Modules

SQL Server PowerShell module

There are two SQL Server PowerShell modules; SqlServer and SQLPS. The SQLPS module is included with the SQL Server installation (for backwards compatibility), but is no longer being updated. The most up-to-date PowerShell module is the SqlServer module. The SqlServer module contains updated versions of the cmdlets in SQLPS, and also includes new cmdlets to support the latest SQL features. Previous versions of the SqlServer module were included with SQL Server Management Studio (SSMS), but only with the 16.x versions of SSMS. To use PowerShell with SSMS 17.0 and later, the SqlServer module must be installed from the PowerShell Gallery.

To install

Install-Module -Name SqlServer -AllowClobber

SqlServer module is in,

C:\Program Files\WindowsPowerShell\Modules

SQLPS and SQLASCMDLETS modules are in,

C:\Program Files (x86)\Microsoft SQL Server\120\Tools\PowerShell\Modules
C:\Program Files (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules

https://docs.microsoft.com/en-us/sql/powershell/download-sql-server-ps-module

https://www.mssqltips.com/sqlservertip/4513/powershell-changes-and-new-cmdlets-for-sql-server-2016/

https://www.red-gate.com/simple-talk/sysadmin/powershell/introduction-to-powershell-with-sql-server-using-invoke-sqlcmd/

Decode-SqlName

Encode-SqlName

SQLSERVER:

Add-RoleMember

Add-SqlAvailabilityDatabase

Add-SqlAvailabilityGroupListenerStaticIp

Add-SqlAzureAuthenticationContext

Add-SqlColumnEncryptionKeyValue

Add-SqlFirewallRule

Add-SqlLogin

Backup-ASDatabase

Backup-SqlDatabase

Complete-SqlColumnMasterKeyRotation

ConvertFrom-EncodedSqlName

ConvertTo-EncodedSqlName

Convert-UrnToPath

Disable-SqlAlwaysOn

Enable-SqlAlwaysOn

Export-SqlVulnerabilityAssessmentBaselineSet

Export-SqlVulnerabilityAssessmentScan

Get-SqlAgent

Get-SqlAgentJob

Get-SqlAgentJobHistory

Get-SqlAgentJobSchedule

Get-SqlAgentJobStep

Get-SqlAgentSchedule

Get-SqlBackupHistory

Get-SqlColumnEncryptionKey

Get-SqlColumnMasterKey

Get-SqlCredential

Get-SqlDatabase

Get-SqlErrorLog

Get-SqlInstance

Get-SqlLogin

Get-SqlSmartAdmin

Grant-SqlAvailabilityGroupCreateAnyDatabase

Import-SqlVulnerabilityAssessmentBaselineSet

Invoke-ASCmd

Invoke-PolicyEvaluation

Invoke-ProcessASDatabase

Invoke-ProcessCube

Invoke-ProcessDimension

Invoke-ProcessPartition

Invoke-ProcessTable

Invoke-Sqlcmd

Invoke-SqlColumnMasterKeyRotation

Invoke-SqlVulnerabilityAssessmentScan

Join-SqlAvailabilityGroup

Merge-Partition

New-RestoreFolder

New-RestoreLocation

New-SqlAvailabilityGroup

New-SqlAvailabilityGroupListener

New-SqlAvailabilityReplica

New-SqlAzureKeyVaultColumnMasterKeySettings

New-SqlBackupEncryptionOption

New-SqlCertificateStoreColumnMasterKeySettings

New-SqlCngColumnMasterKeySettings

New-SqlColumnEncryptionKey

New-SqlColumnEncryptionKeyEncryptedValue

New-SqlColumnEncryptionSettings

New-SqlColumnMasterKey

New-SqlColumnMasterKeySettings

New-SqlCredential

New-SqlCspColumnMasterKeySettings

New-SqlHADREndpoint

New-SqlVulnerabilityAssessmentBaseline

New-SqlVulnerabilityAssessmentBaselineSet

Read-SqlTableData

Read-SqlViewData

Remove-RoleMember

Remove-SqlAvailabilityDatabase

Remove-SqlAvailabilityGroup

Remove-SqlAvailabilityReplica

Remove-SqlColumnEncryptionKey

Remove-SqlColumnEncryptionKeyValue

Remove-SqlColumnMasterKey

Remove-SqlCredential

Remove-SqlFirewallRule

Remove-SqlLogin

Restore-ASDatabase

Restore-SqlDatabase

Resume-SqlAvailabilityDatabase

Revoke-SqlAvailabilityGroupCreateAnyDatabase

Save-SqlMigrationReport

Set-SqlAuthenticationMode

Set-SqlAvailabilityGroup

Set-SqlAvailabilityGroupListener

Set-SqlAvailabilityReplica

Set-SqlAvailabilityReplicaRoleToSecondary

Set-SqlColumnEncryption

Set-SqlCredential

Set-SqlErrorLog

Set-SqlHADREndpoint

Set-SqlNetworkConfiguration

Set-SqlSmartAdmin

Start-SqlInstance

Stop-SqlInstance

Suspend-SqlAvailabilityDatabase

Switch-SqlAvailabilityGroup

Test-SqlAvailabilityGroup

Test-SqlAvailabilityReplica

Test-SqlDatabaseReplicaState

Test-SqlSmartAdmin

Write-SqlTableData

SQL Server Reporting Services Tools

To install

Install-Module -Name ReportingServicesTools

To create a new folder under the root

New-RsFolder -ReportServerUri http://localhost/ReportServer -Path / -Name MSSQLTips -Verbose

To deploy all SSRS files from a local folder to the SSRS

Write-RsFolderContent -ReportServerUri http://localhost/ReportServer -Path "C:\MSSQLTips\Dashboard\" -Destination /MSSQLTips -Verbose

To list all SSRS items from a SSRS folder,

Get-RsFolderContent -ReportServerUri http://localhost/ReportServer -Path /MSSQLTips |             
Format-Table -AutoSize

To deploy an file from a local folder to the SSRS

Write-RsCatalogItem -ReportServerUri http://localhost/ReportServer -Path "C:\MSSQLTips\SQL Server Performance Dashboard\performance_dashboard_main.rdl" -Destination /

To remove a SSRS item,

Remove-RsCatalogItem -ReportServerUri http://localhost/ReportServer -Path /performance_dashboard_main

PowerShell Commands for SQL Server Reporting Services

WebAdministration module

To install

Install-Module WebAdministration

Active Directory module

To install

Import-Module ServerManager
Add-WindowsFeature RSAT-AD-PowerShell

List all domain group

Get-ADGroup -Properties Description | Select Name,Description

List all domain groups filtering by name

Get-ADGroup -Filter {name -like "PON*"} -Properties Description | Select Name,Description

AzureRM

To install,

Install-Module AzureRM -AllowClobber

Installation Error:

The following commands are already available on this system:
'Get-AzureStorageContainerAcl,Start-CopyAzureStorageBlob,Stop-CopyAzureStorageBlob'. This module 'Azure.Storage' may 
override the existing commands. If you still want to install this module 'Azure.Storage', use -AllowClobber parameter.

https://github.com/Azure/azure-powershell/issues/2916

To check if AzureRM is installed on your system,

Get-Module AzureRM -list | Select-Object Name,Version,Path

To load AzureRM module,

Import-Module AzureRM

Database modules

MongoDB Cmdlets for PowerShell

https://github.com/nightroman/Mdbc

PS> Install-Module Mdbc

Sample code:

# Load the module
Import-Module Mdbc

# Connect the new collection test.test
Connect-Mdbc . test test -NewCollection

# Add some test data
@{_id=1; value=42}, @{_id=2; value=3.14} | Add-MdbcData

# Get all data as custom objects and show them in a table
Get-MdbcData -As PS | Format-Table -AutoSize | Out-String

# Query a document by _id using a query expression
$data = Get-MdbcData (New-MdbcQuery _id -EQ 1)
$data

# Update the document, set the 'value' to 100
$data._id | Update-MdbcData (New-MdbcUpdate -Set @{value = 100})

# Query the document using a simple _id query
Get-MdbcData $data._id

# Remove the document
$data._id | Remove-MdbcData

# Count remaining documents, 1 is expected
Get-MdbcData -Count

Connectivity

Posh-SSH

Posh-SSH: Open Source SSH PowerShell Module

Skype for Business Online

https://www.microsoft.com/en-us/download/details.aspx?id=39366

Set up your computer for Windows PowerShell

Misc. Modules

Pester module

Pester is the ubiquitous test and mock framework for PowerShell.

PowerShell Framework modules

PSFramework module

Install

Install-Module PSFramework

PSFramework Documentation

https://www.powershellgallery.com/packages/PSFramework/

PSModuleDevelopment module

Install

Install-Module PSModuleDevelopment

https://psframework.org/documentation/documents/psmoduledevelopment.html

PSUtil module

Install

Install-Module PSUtil

https://psframework.org/documentation/documents/psutil.html

results matching ""

    No results matching ""