This module contains a collection of PowerShell functions I have found I use/reuse frequently. Consequently, I created this module to include those functions.
To publish this module to Azure DevOps I used the NuGet package provider. Therefore, NuGet must be installed on the computer.
$pkgProviders = Get-PackageProvider -ListAvailable -Force -ErrorAction Continue
if (-not ($pkgProviders.Name.Contains('Nuget')))
{
try
{
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
}
catch
{
$errorMessage = "{0}: {1}" -f $Error[0], $Error[0].InvocationInfo.PositionMessage
Write-Error $errorMessage -ErrorAction Continue
}
}
The PowerShellGet module is also required. It can be installed from PowerShellGallery.com
Install-Module PowerShellGet -Repository PSGallery -Force
One option to authenticate to Azure DevOps is using a Personal Access Token (PAT). See: https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops
Once the PAT token has been generated, save it in a secure location. I use Keepass to save mine for reuse.
$creds = Get-Credential
User is not required, however I typically enter my personal e-mail address. Password should be your PAT token.
Register-PSRepository -Name HMMPackages -SourceLocation 'Insert SourceLocation created when artifact repository was created' -InstallationPolicy Trusted -Credential $creds
.\nuget.exe sources Add -Name HMMPackages -Source 'Insert repository source location to .json file' -Force
\nuget.exe spec 'HelperFunctions' -Force
NOTE: Module version in .psd1 file must match version number in .nuspec file. NOTE: In order to work around the “WARNING: Issue: PowerShell file outside tools folder.” use the -NoPackageAnalysis parameter
.\nuget pack "HelperFunctions.nuspec" -NoPackageAnalysis
.\nuget.exe push -Source 'Insert Repository Name Here' -ApiKey az (can really be anything) "HelperFunctions.0.0.1.nupkg"
Find-Module -Repository 'HelperFunctions' -Credential $creds
End with an example of getting some data out of the system or using it for a little demo
At present, I have not yet created Pester tests for all functions. I have run each function through PSScriptAnalyzer.
``` Install-Module ‘HelpFunctions’ -Repository ‘Insert PS Repository Name’ -Credential $creds -Force -AllowClobber
Update-Module -Name HelperFunctions -Force
We use SemVer for versioning. For the versions available, see the tags on this repository.
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details