-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-PSModuleAliasesToExport.ps1
More file actions
36 lines (29 loc) · 1.41 KB
/
Get-PSModuleAliasesToExport.ps1
File metadata and controls
36 lines (29 loc) · 1.41 KB
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
function Get-PSModuleAliasesToExport {
<#
.SYNOPSIS
Gets the aliases to export from the module manifest.
.DESCRIPTION
This function will get the aliases to export from the module manifest.
.EXAMPLE
Get-PSModuleAliasesToExport -SourceFolderPath 'C:\MyModule\src\MyModule'
#>
[CmdletBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Scope = 'Function', Justification = 'Want to just write to the console, not the pipeline.')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Scope = 'Function', Justification = 'Contains long links.')]
param(
# Path to the folder where the module source code is located.
[Parameter(Mandatory)]
[string] $SourceFolderPath
)
$manifestPropertyName = 'AliasesToExport'
$moduleName = Split-Path -Path $SourceFolderPath -Leaf
$manifestFileName = "$moduleName.psd1"
$manifestFilePath = Join-Path -Path $SourceFolderPath $manifestFileName
$manifest = Get-ModuleManifest -Path $manifestFilePath -Verbose:$false
Write-Host "[$manifestPropertyName]"
$aliasesToExport = (($manifest.AliasesToExport).count -eq 0) -or [string]::IsNullOrEmpty($manifest.AliasesToExport) ? '*' : $manifest.AliasesToExport
$aliasesToExport | ForEach-Object {
Write-Host "[$manifestPropertyName] - [$_]"
}
$aliasesToExport
}