Skip to content

theohbrothers/PSMockModule

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PSMockModule

badge-build-azuredevops-build-img badge-version-github-release-img badge-version-powershellgallery-releases-img

Introduction

A mock PowerShell module for templating and reference.

Requirements

Installation

First, ensure PSGallery is registered as a PowerShell repository:

Register-PSRepository -Default -Verbose

To install the module:

# Latest, for the current user
Install-Module -Name PSMockModule -Repository PSGallery -Scope CurrentUser -Verbose

# Specific version, for the current user
Install-Module -Name PSMockModule -Repository PSGallery -RequiredVersion x.x.x -Scope CurrentUser -Verbose

# Latest, for all users
Install-Module -Name PSMockModule -Repository PSGallery -Scope AllUsers -Verbose

Usage

Functions

Mock-Function1 [<CommonParameters>]
Mock-Function2 [<CommonParameters>]

To run Mock-Function1:

Mock-Function1 -Verbose

To run Mock-Function2:

Mock-Function2 -Verbose

To list all available functions of the module:

Get-Command -Module PSMockModule

Administration

Versions

To list versions of the module on PSGallery:

# Latest
Find-Module -Name PSMockModule -Repository PSGallery -Verbose

# All versions
Find-Module -Name PSMockModule -Repository PSGallery -AllVersions -Verbose

To update the module (Existing versions are left intact):

# Latest
Update-Module -Name PSMockModule -Verbose

# Specific version
Update-Module -Name PSMockModule -RequiredVersion x.x.x -Verbose

To uninstall the module:

# Latest
Uninstall-Module -Name PSMockModule -Verbose

# All versions
Uninstall-Module -Name PSMockModule -AllVersions -Verbose

# To uninstall all other versions other than x.x.x
Get-Module -Name PSMockModule -ListAvailable | ? { $_.Version -ne 'x.x.x' } | % { Uninstall-Module -Name $_.Name -RequiredVersion $_.Version -Verbose }

# Tip: Simulate uninstalls with -WhatIf

Repositories

To get all registered PowerShell repositories:

Get-PSRepository -Verbose

To set the installation policy for the PSGallery repository:

# PSGallery (trusted)
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted -Verbose

# PSGallery (untrusted)
Set-PSRepository -Name PSGallery -InstallationPolicy Untrusted -Verbose

Development

To import / re-import the module:

# Installed version
Import-Module -Name PSMockModule -Force -Verbose

# Project version
Import-Module .\src\PSMockModule\PSMockModule.psm1 -Force -Verbose

To remove imported functions of the module:

Remove-Module -Name PSMockModule -Verbose

To list imported versions of the module:

Get-Module -Name PSMockModule

To list all installed versions of the module available for import:

Get-Module -Name PSMockModule -ListAvailable -Verbose