functions/Get-PuppetizedModuleName.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
function Get-PuppetizedModuleName { <# .SYNOPSIS Get a valid puppet module name from a PowerShell Module name .DESCRIPTION Get a valid puppet module name from a PowerShell Module name .PARAMETER Name The name of the PowerShell module you want to puppetize .EXAMPLE Get-PuppetizedModuleName -Name Azure.Something.Or.Other This will return 'azure_something_or_other', which is a valid Puppet module name. #> [cmdletbinding()] [OutputType([String])] param ( [string]$Name ) Begin {} Process { # Puppet module names must be lowercase: $PuppetizedName = $Name.ToLowerInvariant() # Puppet module names may only include lowercase letters, digits, and underscores $PuppetizedName = $PuppetizedName -replace '[^a-z0-9_]', '_' If ($PuppetizedName -match '^\d') { # This is a... not good compromise, but it works "a$PuppetizedName" } Else { $PuppetizedName } } End {} } |