-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathCreate-ModuleMappingFile.ps1
More file actions
47 lines (39 loc) · 1.94 KB
/
Copy pathCreate-ModuleMappingFile.ps1
File metadata and controls
47 lines (39 loc) · 1.94 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
37
38
39
40
41
42
43
44
45
46
47
# ------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
# ------------------------------------------------------------------------------
function Create-ModuleMappingFile {
[cmdletbinding()]
param(
[ValidateSet('Entra', 'EntraBeta')]
[string]
$ModuleName = 'Entra' # Default to "Entra" if no argument is provided
)
PROCESS {
if($ModuleName -eq 'Entra'){
$rootModuleName = 'Microsoft.Entra'
$docFolderName = 'entra-powershell-v1.0'
}
elseif($ModuleName -eq 'EntraBeta'){
$rootModuleName = 'Microsoft.Entra.Beta'
$docFolderName = 'entra-powershell-beta'
}
$moduleFolderPath = (Join-Path $PSScriptRoot "../module/docs/$docFolderName")
Write-Host "[ModuleFolderPath] $moduleFolderPath" -ForegroundColor 'Green'
$subModules = @(Get-ChildItem -Path $moduleFolderPath -Directory)
Write-Host "[subModules] $($subModules.Count)" -ForegroundColor 'Green'
$mapping = @{}
foreach($subModuleName in $subModules.Name){
$subModuleFolderPath = (Join-Path $moduleFolderPath $subModuleName)
Write-Host "[ModuleFolderPath] $subModuleFolderPath" -ForegroundColor 'Green'
$subModulesDocs = @(Get-ChildItem -Path $subModuleFolderPath -File)
foreach($subModuleDoc in $subModulesDocs){
if($subModuleDoc.BaseName -ne 'Enable-EntraAzureADAlias'){
$mapping.Add($subModuleDoc.BaseName,$subModuleName)
}
}
}
# Save the mapping to a JSON file
$mappingFilePath = (Join-Path $PSScriptRoot "$ModuleName-ModuleMapping.json")
$mapping | ConvertTo-Json -Depth 10 | Out-File -FilePath $mappingFilePath -Encoding utf8
}
}