Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions build/Create-ModuleMapping.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@

#This function uses the moduleMapping.json to split the docs to subdirectories i.e. Key =SubModule name and
# Value =an array of strings representing the files in that directory
. ./common-functions.ps1

param (
[string]$Module = "Entra" # Default to "Entra" if no argument is provided
)

. (Join-Path $psscriptroot "/common-functions.ps1")

function Get-DirectoryFileMap {
param (
[string]$Source = 'Entra' # Default to 'Entra'
Expand All @@ -14,12 +20,12 @@ function Get-DirectoryFileMap {
# Determine the root directory and the output based on the Source parameter
switch ($Source) {
'Entra' {
$RootDirectory = "../module_legacy/Entra/Microsoft.Graph.Entra/"
$OutputDirectory = '../module_legacy/Entra/config/'
$RootDirectory = (Join-Path $PSScriptRoot "../module/Entra/Microsoft.Entra/")
$OutputDirectory = (Join-Path $PSScriptRoot '../module/Entra/config/')
}
'EntraBeta' {
$RootDirectory = "../module_legacy/EntraBeta/Microsoft.Graph.Entra.Beta/"
$OutputDirectory = "../module_legacy/EntraBeta/config/"
$RootDirectory = (Join-Path $PSScriptRoot"../module/EntraBeta/Microsoft.Entra.Beta/")
$OutputDirectory = (Join-Path $PSScriptRoot"../module/EntraBeta/config/")
}
default {
Log-Message "Invalid Source specified. Use 'Entra' or 'EntraBeta'." 'Error'
Expand Down Expand Up @@ -47,16 +53,18 @@ function Get-DirectoryFileMap {

# Get all the subdirectories under the root directory
$subDirectories = Get-ChildItem -Path $RootDirectory -Directory

$filesToSkip=@('Enable-EntraAzureADAliases','Get-EntraUnsupportedCommand','New-EntraCustomHeaders','Enable-EntraBetaAzureADAliases','Get-EntraBetaUnsupportedCommand','New-EntraBetaCustomHeaders')
foreach ($subDir in $subDirectories) {
Log-Message "Processing subdirectory '$($subDir.Name)'." 'Info'

# Get the files in each sub-directory without their extensions
$files = Get-ChildItem -Path $subDir.FullName -File | ForEach-Object {
$fileName = [System.IO.Path]::GetFileNameWithoutExtension($_.Name)
# Map the file name to the directory name
$fileDirectoryMap[$fileName] = $subDir.Name
if($fileName -notin $filesToSkip){
$fileDirectoryMap[$fileName] = $subDir.Name
Log-Message "Mapped file '$fileName' to directory '$($subDir.Name)'." 'Info'
}
}
}

Expand All @@ -72,4 +80,4 @@ function Get-DirectoryFileMap {
Log-Message "moduleMapping.json has been created at '$outputFilePath'." 'Info'
}

Get-DirectoryFileMap -Source 'Entra'
Get-DirectoryFileMap -Source $Module
81 changes: 49 additions & 32 deletions build/Split-Docs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,29 @@
#This function copies the docs using the moduleMapping.json into their submodule directories
# i.e. For each entry, it will use the Key(cmdlet name) and map it to the Value(A subdirectory created in the respective docs directory)

. (Join-Path $psscriptroot "/common-functions.ps1")
param (
[string]$Module = "Entra" # Default to "Entra" if no argument is provided
)

.(Join-Path $psscriptroot "/common-functions.ps1")


function Split-Docs {
param (
[string]$Module = 'Entra', # Default to 'Entra'
[string]$OutputDirectory # Allow custom output directory
[string]$Module = 'Entra'
)

# Determine source directories and mapping file paths based on the Source parameter
switch ($Module) {
'Entra' {
$DocsSourceDirectory = "../module_legacy/docs/entra-powershell-v1.0/Microsoft.Graph.Entra"
$MappingFilePath = '../module/Entra/config/moduleMapping.json'
$OutputDirectory='../module/docs/entra-powershell-v1.0'
$DocsSourceDirectory = (Join-Path $PSScriptRoot "../module_legacy/docs/entra-powershell-v1.0/Microsoft.Graph.Entra")
$MappingFilePath = (Join-Path $PSScriptRoot '../module/Entra/config/moduleMapping.json')
$OutputDirectory= (Join-Path $PSScriptRoot '../module/docs/entra-powershell-v1.0')
}
'EntraBeta' {
$DocsSourceDirectory = "../module_legacy/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta"
$MappingFilePath = "../module/EntraBeta/config/moduleMapping.json"
$OutputDirectory="../module/docs/entra-powershell-beta"
$DocsSourceDirectory = (Join-Path $PSScriptRoot "../module_legacy/docs/entra-powershell-beta/Microsoft.Graph.Entra.Beta")
$MappingFilePath = (Join-Path $PSScriptRoot "../module/EntraBeta/config/moduleMapping.json")
$OutputDirectory= (Join-Path $PSScriptRoot "../module/docs/entra-powershell-beta")
}
default {
Log-Message -Message "[Split-Docs]: Invalid Source specified. Use 'Entra' or 'EntraBeta'." -Level 'ERROR'
Expand All @@ -50,34 +53,48 @@ function Split-Docs {
Log-Message -Message "[Split-Docs]: Created directory: $TargetRootDirectory" -Level 'SUCCESS'
}

# Iterate over each file-directory pair in the moduleMapping.json
foreach ($fileEntry in $moduleMapping.PSObject.Properties) {
$fileName = $fileEntry.Name # Key (file name without extension)
$subDirName = $fileEntry.Value # Value (sub-directory name)
# Ensure UnMappedDocs directory exists at the same level as the OutputDirectory
$unMappedDocsDirectory = Join-Path -Path (Split-Path $TargetRootDirectory) -ChildPath 'UnMappedDocs'
if (-not (Test-Path -Path $unMappedDocsDirectory -PathType Container)) {
New-Item -Path $unMappedDocsDirectory -ItemType Directory | Out-Null
Log-Message -Message "[Split-Docs]: Created 'UnMappedDocs' directory: $unMappedDocsDirectory" -Level 'SUCCESS'
}

# Create the sub-directory under the output root directory if it doesn't exist
$targetSubDir = Join-Path -Path $TargetRootDirectory -ChildPath $subDirName
# Iterate over each file in the DocsSourceDirectory
$filesInSource = Get-ChildItem -Path $DocsSourceDirectory -Filter "*.md"

if($subDirName -eq 'Migration' -or $subDirName -eq 'Invitations'){
Log-Message "[Split-Docs]: Skipping $subDirName" -Level 'WARNING'
continue
}
if (-not (Test-Path -Path $targetSubDir -PathType Container)) {
New-Item -Path $targetSubDir -ItemType Directory | Out-Null
Log-Message -Message "[Split-Docs]: Created sub-directory: $targetSubDir" -Level 'SUCCESS'
}
foreach ($file in $filesInSource) {
$fileNameWithoutExtension = [System.IO.Path]::GetFileNameWithoutExtension($file.Name)

# Check if the fileName exists in the mapping
$subDirName = $moduleMapping.PSObject.Properties.Name | Where-Object { $_ -eq $fileNameWithoutExtension }

if ($subDirName) {
# If a subdir is mapped, proceed as before
$subDirName = $moduleMapping.$fileNameWithoutExtension
$targetSubDir = Join-Path -Path $TargetRootDirectory -ChildPath $subDirName

if($subDirName -eq 'Migration' -or $subDirName -eq 'Invitations'){
Log-Message "[Split-Docs]: Skipping $subDirName" -Level 'WARNING'
continue
}
if (-not (Test-Path -Path $targetSubDir -PathType Container)) {
New-Item -Path $targetSubDir -ItemType Directory | Out-Null
Log-Message -Message "[Split-Docs]: Created sub-directory: $targetSubDir" -Level 'SUCCESS'
}

# Build the full source file path for the .md file
$sourceFile = Join-Path -Path $DocsSourceDirectory -ChildPath "$fileName.md"
if (Test-Path -Path $sourceFile -PathType Leaf) {
# Copy the .md file to the target sub-directory
Copy-Item -Path $sourceFile -Destination $targetSubDir
Log-Message -Message "[Split-Docs]: Copied '$sourceFile' to '$targetSubDir'" -Level 'SUCCESS'
} else {
# Log a warning if the .md file doesn't exist in the source directory
Log-Message -Message "[Split-Docs]: File '$fileName.md' not found in '$DocsSourceDirectory'" -Level 'WARNING'
Copy-Item -Path $file.FullName -Destination $targetSubDir
Log-Message -Message "[Split-Docs]: Copied '$file' to '$targetSubDir'" -Level 'SUCCESS'
}
else {
# If no mapping found, move it to UnMappedDocs
Copy-Item -Path $file.FullName -Destination $unMappedDocsDirectory
Log-Message -Message "[Split-Docs]: No mapping for '$fileNameWithoutExtension'. Moved to '$unMappedDocsDirectory'" -Level 'INFO'
}
}

Log-Message -Message "[Split-Docs]: Markdown file copying complete." -Level 'INFO'
}
}

Split-Docs -Module $Module
2 changes: 2 additions & 0 deletions build/Split-EntraModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ param (
# Import the necessary scripts
. (Join-Path $psscriptroot "/common-functions.ps1")
. (Join-Path $psscriptroot "../src/EntraModuleSplitter.ps1")
.(Join-Path $psscriptroot "/Split-Docs.ps1")



Expand All @@ -18,3 +19,4 @@ param (
$entraModuleSplitter = [EntraModuleSplitter]::new()
$entraModuleSplitter.SplitEntraModule($Module) # Pass the module argument
$entraModuleSplitter.ProcessEntraAzureADAliases($Module)

5 changes: 4 additions & 1 deletion module/Entra/config/ModuleMetadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"guid": "742dccd1-bf4b-46a0-a3f2-14e0bb508233",
"authors": "Microsoft",
"owners": "Microsoft",
"entraDescription":"Microsoft Entra Powershell",
"description": "Microsoft Entra PowerShell v1.0: Microsoft Entra PowerShell is a scenario-driven module that allows administrators to efficiently manage Entra ID resources, including users, groups, applications, and policies, among others",
"requireLicenseAcceptance": "true",
"requiredModules" : [
Expand Down Expand Up @@ -31,5 +32,7 @@
],
"releaseNotes": "See https://github.com/microsoftgraph/entra-powershell.",
"version": "0.20.0",
"Prerelease": "preview"
"Prerelease": "preview",
"dotNetVersion":"4.7.2",
"powershellVersion":"5.1"
}
6 changes: 4 additions & 2 deletions module/Entra/config/moduleMapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
"New-EntraOauth2PermissionGrant": "SignIns",
"New-EntraConditionalAccessPolicy": "SignIns",
"New-EntraIdentityProvider": "SignIns",
"New-EntraInvitation": "Invitations",
"New-EntraInvitation": "SignIns",
"New-EntraPermissionGrantConditionSet": "SignIns",
"New-EntraPermissionGrantPolicy": "SignIns",
"Remove-EntraConditionalAccessPolicy": "SignIns",
Expand All @@ -189,6 +189,7 @@
"Set-EntraTenantDetail": "DirectoryManagement",
"Add-EntraScopedRoleMembership": "DirectoryManagement",
"Get-EntraUser": "Users",
"Get-EntraUserAuthenticationMethod":"SignIns",
"Get-EntraUserAppRoleAssignment": "Users",
"Get-EntraUserCreatedObject": "Users",
"Get-EntraUserDirectReport": "Users",
Expand Down Expand Up @@ -260,5 +261,6 @@
"Remove-EntraServicePrincipalAppRoleAssignment": "Applications",
"Set-EntraDirectoryRoleDefinition": "Governance",
"Update-EntraUserFromFederated": "Users",
"Get-EntraDomainServiceConfigurationRecord":"DirectoryManagement"
"Get-EntraDomainServiceConfigurationRecord":"DirectoryManagement",
"Get-EntraUserAuthenticationRequirement":"SignIns"
}
5 changes: 4 additions & 1 deletion module/EntraBeta/config/ModuleMetadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"guid": "3a8a0270-121c-4455-845d-497458213f96",
"authors": "Microsoft",
"owners": "Microsoft",
"entraDescription":"Microsoft Entra Powershell",
"description": "Microsoft Entra PowerShell Beta: Microsoft Entra PowerShell is a scenario-driven module that allows administrators to efficiently manage Entra ID resources, including users, groups, applications, and policies, among others",
"requireLicenseAcceptance": "true",
"requiredModules" : [
Expand Down Expand Up @@ -32,5 +33,7 @@
],
"releaseNotes": "See https://github.com/microsoftgraph/entra-powershell.",
"version": "0.20.0",
"Prerelease": "preview"
"Prerelease": "preview",
"dotNetVersion":"4.7.2",
"powershellVersion":"5.1"
}
9 changes: 5 additions & 4 deletions src/CompatibilityAdapterBuilder.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,16 @@ class CompatibilityAdapterBuilder {
$data = $this.Map()

$psm1FileContent = $this.GetFileHeader()
$doubleSpace="`n`n"
foreach($cmd in $data.Commands) {
$psm1FileContent += $cmd.CommandBlock
$psm1FileContent += $doubleSpace+$cmd.CommandBlock
}

$psm1FileContent += $this.GetUnsupportedCommand()
$psm1FileContent +=$doubleSpace+ $this.GetUnsupportedCommand()

$psm1FileContent += $this.GetAlisesFunction()
$psm1FileContent += $doubleSpace+$this.GetAlisesFunction()
foreach($function in $this.HelperCmdletsToExport.GetEnumerator()){
$psm1FileContent += $function.Value
$psm1FileContent += $doubleSpace+$function.Value
}
$psm1FileContent += $this.GetExportMemeber()
$psm1FileContent += $this.SetMissingCommands()
Expand Down
6 changes: 3 additions & 3 deletions src/EntraModuleBuilder.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,9 @@ $($requiredModulesEntries -join ",`n")
CompanyName = $($content.owners)
FileList = @("$manifestFileName", "$moduleFileName", "$helpFileName")
RootModule = "$moduleFileName"
Description = 'Microsoft Graph Entra PowerShell.'
DotNetFrameworkVersion = $([System.Version]::Parse('4.7.2'))
PowerShellVersion = $([System.Version]::Parse('5.1'))
Description = $content.EntraDescription
DotNetFrameworkVersion = $([System.Version]::Parse($content.DotNetVersion))
PowerShellVersion = $([System.Version]::Parse($content.PowershellVersion))
CompatiblePSEditions = @('Desktop', 'Core')
RequiredModules = $requiredModules
NestedModules = @()
Expand Down