From f2978b3c16ba8da74ad1b85c1db0f5263920cddb Mon Sep 17 00:00:00 2001 From: Microsoft Graph DevX Tooling Date: Tue, 1 Apr 2025 11:09:04 +0300 Subject: [PATCH 1/3] Added script for adding metadata for authentication module --- .../custom/common/MgCommandMetadata.json | 168 ++++++++++ tools/AuthModuleMetadata.ps1 | 315 ++++++++++++++++++ 2 files changed, 483 insertions(+) create mode 100644 tools/AuthModuleMetadata.ps1 diff --git a/src/Authentication/Authentication/custom/common/MgCommandMetadata.json b/src/Authentication/Authentication/custom/common/MgCommandMetadata.json index d097f3a32ee..e17813df44c 100644 --- a/src/Authentication/Authentication/custom/common/MgCommandMetadata.json +++ b/src/Authentication/Authentication/custom/common/MgCommandMetadata.json @@ -592123,5 +592123,173 @@ "ApiReferenceLink": null, "Uri": "/users/{user-id}/mobileAppTroubleshootingEvents/{mobileAppTroubleshootingEvent-id}/appLogCollectionRequests/{appLogCollectionRequest-id}", "Module": "Beta.Devices.CorporateManagement" + }, + { + "Command": "Connect-MgGraph", + "Method": "POST", + "Module": "Authentication", + "CommandAlias": null, + "Permissions": [], + "ApiVersion": null, + "OutputType": "System.Object", + "Variants": [], + "ApiReferenceLink": "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/connect-mggraph?view=graph-powershell-1.0", + "Uri": null + }, + { + "Command": "Add-MgEnvironment", + "Method": null, + "Module": "Authentication", + "CommandAlias": null, + "Permissions": [], + "ApiVersion": null, + "OutputType": "Microsoft.Graph.PowerShell.Authentication.Models.GraphEnvironment", + "Variants": [], + "ApiReferenceLink": "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/add-mgenvironment?view=graph-powershell-1.0", + "Uri": null + }, + { + "Command": "Get-MgEnvironment", + "Method": null, + "Module": "Authentication", + "CommandAlias": null, + "Permissions": [], + "ApiVersion": null, + "OutputType": "Microsoft.Graph.PowerShell.Authentication.Models.GraphEnvironment", + "Variants": [], + "ApiReferenceLink": "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/get-mgenvironment?view=graph-powershell-1.0", + "Uri": null + }, + { + "Command": "Remove-MgEnvironment", + "Method": null, + "Module": "Authentication", + "CommandAlias": null, + "Permissions": [], + "ApiVersion": null, + "OutputType": "System.Object", + "Variants": [], + "ApiReferenceLink": "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/remove-mgenvironment?view=graph-powershell-1.0", + "Uri": null + }, + { + "Command": "Set-MgEnvironment", + "Method": null, + "Module": "Authentication", + "CommandAlias": null, + "Permissions": [], + "ApiVersion": null, + "OutputType": "System.Object", + "Variants": [], + "ApiReferenceLink": "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/set-mgenvironment?view=graph-powershell-1.0", + "Uri": null + }, + { + "Command": "Disconnect-MgGraph", + "Method": null, + "Module": "Authentication", + "CommandAlias": null, + "Permissions": [], + "ApiVersion": null, + "OutputType": "Microsoft.Graph.PowerShell.Authentication.IAuthContext", + "Variants": [], + "ApiReferenceLink": "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/disconnect-mggraph?view=graph-powershell-1.0", + "Uri": null + }, + { + "Command": "Find-MgGraphCommand", + "Method": null, + "Module": "Authentication", + "CommandAlias": null, + "Permissions": [], + "ApiVersion": null, + "OutputType": "Microsoft.Graph.PowerShell.Authentication.Models.IGraphCommand", + "Variants": [], + "ApiReferenceLink": "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/find-mggraphcommand?view=graph-powershell-1.0", + "Uri": null + }, + { + "Command": "Find-MgGraphPermission", + "Method": null, + "Module": "Authentication", + "CommandAlias": null, + "Permissions": [], + "ApiVersion": null, + "OutputType": "System.Array", + "Variants": [], + "ApiReferenceLink": "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/find-mggraphpermission?view=graph-powershell-1.0", + "Uri": null + }, + { + "Command": "Get-MgContext", + "Method": null, + "Module": "Authentication", + "CommandAlias": null, + "Permissions": [], + "ApiVersion": null, + "OutputType": "Microsoft.Graph.PowerShell.Authentication.IAuthContext", + "Variants": [], + "ApiReferenceLink": "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/get-mgcontext?view=graph-powershell-1.0", + "Uri": null + }, + { + "Command": "Get-MgGraphOption", + "Method": null, + "Module": "Authentication", + "CommandAlias": null, + "Permissions": [], + "ApiVersion": null, + "OutputType": "Microsoft.Graph.PowerShell.Authentication.IGraphOption", + "Variants": [], + "ApiReferenceLink": "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/get-mggraphoption?view=graph-powershell-1.0", + "Uri": null + }, + { + "Command": "Get-MgRequestContext", + "Method": null, + "Module": "Authentication", + "CommandAlias": null, + "Permissions": [], + "ApiVersion": null, + "OutputType": "Microsoft.Graph.PowerShell.Authentication.Core.Interfaces.IRequestContext", + "Variants": [], + "ApiReferenceLink": "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/get-mgrequestcontext?view=graph-powershell-1.0", + "Uri": null + }, + { + "Command": "Invoke-MgGraphRequest", + "Method": null, + "Module": "Authentication", + "CommandAlias": null, + "Permissions": [], + "ApiVersion": null, + "OutputType": "System.Object", + "Variants": [], + "ApiReferenceLink": "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/invoke-mggraphrequest?view=graph-powershell-1.0", + "Uri": null + }, + { + "Command": "Set-MgGraphOption", + "Method": null, + "Module": "Authentication", + "CommandAlias": null, + "Permissions": [], + "ApiVersion": null, + "OutputType": "System.Object", + "Variants": [], + "ApiReferenceLink": "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/set-mggraphoption?view=graph-powershell-1.0", + "Uri": null + }, + { + "Command": "Set-MgRequestContext", + "Method": null, + "Module": "Authentication", + "CommandAlias": null, + "Permissions": [], + "ApiVersion": null, + "OutputType": "Microsoft.Graph.PowerShell.Authentication.Core.Interfaces.IRequestContext", + "Variants": [], + "ApiReferenceLink": "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/set-mgrequestcontext?view=graph-powershell-1.0", + "Uri": null } ] diff --git a/tools/AuthModuleMetadata.ps1 b/tools/AuthModuleMetadata.ps1 new file mode 100644 index 00000000000..18d700d4e25 --- /dev/null +++ b/tools/AuthModuleMetadata.ps1 @@ -0,0 +1,315 @@ +#Load MgCommandMetadata.json file +$CommandMetadataFile = (Join-Path $PSScriptRoot "../src\Authentication/Authentication/custom/common/MgCommandMetadata.json") +#Convert JSON to HashTable +$CommandMetadata = Get-Content $CommandMetadataFile | ConvertFrom-Json -AsHashTable + +#Check if Connect-MgGraph is in the list of commands +$ConnectCommand = $CommandMetadata | Where-Object { $_.Name -eq "Connect-MgGraph" } +if ($null -eq $ConnectCommand) { + #Add Connect-MgGraph to the list of commands + $CommandMetadata += [pscustomobject]@{ + Command = "Connect-MgGraph" + Method = "POST" + Module = "Authentication" + CommandAlias = $null + Permissions = @() + ApiVersion = $null + OutputType = "System.Object" + Variants = @() + ApiReferenceLink = "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/connect-mggraph?view=graph-powershell-1.0" + Uri = $null + } + # Update the file + $FinalConnectMgGraphOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 + + $FinalConnectMgGraphOutPut | Set-Content -Path $CommandMetadataFile -Force + Write-Host "Connect-MgGraph command added to the list of commands in MgCommandMetadata.json" +} + +#Check if Add-MgEnvironment is in the list of commands +$AddEnvironmentCommand = $CommandMetadata | Where-Object { $_.Name -eq "Add-MgEnvironment" } +if ($null -eq $AddEnvironmentCommand) { + #Add Add-MgEnvironment to the list of commands + $CommandMetadata += [pscustomobject]@{ + Command = "Add-MgEnvironment" + Method = $null + Module = "Authentication" + CommandAlias = $null + Permissions = @() + ApiVersion = $null + OutputType = "Microsoft.Graph.PowerShell.Authentication.Models.GraphEnvironment" + Variants = @() + ApiReferenceLink = "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/add-mgenvironment?view=graph-powershell-1.0" + Uri = $null + } + # Update the file + $FinalAddEnvironmentOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 + + $FinalAddEnvironmentOutPut | Set-Content -Path $CommandMetadataFile -Force + Write-Host "Add-MgEnvironment command added to the list of commands in MgCommandMetadata.json" +} +#Check if Get-MgEnvironment is in the list of commands +$GetEnvironmentCommand = $CommandMetadata | Where-Object { $_.Name -eq "Get-MgEnvironment" } +if ($null -eq $GetEnvironmentCommand) { + #Add Get-MgEnvironment to the list of commands + $CommandMetadata += [pscustomobject]@{ + Command = "Get-MgEnvironment" + Method = $null + Module = "Authentication" + CommandAlias = $null + Permissions = @() + ApiVersion = $null + OutputType = "Microsoft.Graph.PowerShell.Authentication.Models.GraphEnvironment" + Variants = @() + ApiReferenceLink = "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/get-mgenvironment?view=graph-powershell-1.0" + Uri = $null + } + # Update the file + $FinalGetEnvironmentOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 + + $FinalGetEnvironmentOutPut | Set-Content -Path $CommandMetadataFile -Force + Write-Host "Get-MgEnvironment command added to the list of commands in MgCommandMetadata.json" +} +#Check if Remove-MgEnvironment is in the list of commands +$RemoveEnvironmentCommand = $CommandMetadata | Where-Object { $_.Name -eq "Remove-MgEnvironment" } +if ($null -eq $RemoveEnvironmentCommand) { + #Add Remove-MgEnvironment to the list of commands + $CommandMetadata += [pscustomobject]@{ + Command = "Remove-MgEnvironment" + Method = $null + Module = "Authentication" + CommandAlias = $null + Permissions = @() + ApiVersion = $null + OutputType = "System.Object" + Variants = @() + ApiReferenceLink = "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/remove-mgenvironment?view=graph-powershell-1.0" + Uri = $null + } + # Update the file + $FinalRemoveEnvironmentOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 + + $FinalRemoveEnvironmentOutPut | Set-Content -Path $CommandMetadataFile -Force + Write-Host "Remove-MgEnvironment command added to the list of commands in MgCommandMetadata.json" +} +#Check if Set-MgEnvironment is in the list of commands +$SetEnvironmentCommand = $CommandMetadata | Where-Object { $_.Name -eq "Set-MgEnvironment" } +if ($null -eq $SetEnvironmentCommand) { + #Add Set-MgEnvironment to the list of commands + $CommandMetadata += [pscustomobject]@{ + Command = "Set-MgEnvironment" + Method = $null + Module = "Authentication" + CommandAlias = $null + Permissions = @() + ApiVersion = $null + OutputType = "System.Object" + Variants = @() + ApiReferenceLink = "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/set-mgenvironment?view=graph-powershell-1.0" + Uri = $null + } + # Update the file + $FinalSetEnvironmentOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 + + $FinalSetEnvironmentOutPut | Set-Content -Path $CommandMetadataFile -Force + Write-Host "Set-MgEnvironment command added to the list of commands in MgCommandMetadata.json" +} +#Check if Disconnect-MgGraph is in the list of commands +$DisconnectCommand = $CommandMetadata | Where-Object { $_.Name -eq "Disconnect-MgGraph" } +if ($null -eq $DisconnectCommand) { + #Add Disconnect-MgGraph to the list of commands + $CommandMetadata += [pscustomobject]@{ + Command = "Disconnect-MgGraph" + Method = $null + Module = "Authentication" + CommandAlias = $null + Permissions = @() + ApiVersion = $null + OutputType = "Microsoft.Graph.PowerShell.Authentication.IAuthContext" + Variants = @() + ApiReferenceLink = "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/disconnect-mggraph?view=graph-powershell-1.0" + Uri = $null + } + # Update the file + $FinalDisconnectOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 + + $FinalDisconnectOutPut | Set-Content -Path $CommandMetadataFile -Force + Write-Host "Disconnect-MgGraph command added to the list of commands in MgCommandMetadata.json" +} +#Check if Find-MgGraphCommand is in the list of commands +$FindCommand = $CommandMetadata | Where-Object { $_.Name -eq "Find-MgGraphCommand" } +if ($null -eq $FindCommand) { + #Add Find-MgGraphCommand to the list of commands + $CommandMetadata += [pscustomobject]@{ + Command = "Find-MgGraphCommand" + Method = $null + Module = "Authentication" + CommandAlias = $null + Permissions = @() + ApiVersion = $null + OutputType = "Microsoft.Graph.PowerShell.Authentication.Models.IGraphCommand" + Variants = @() + ApiReferenceLink = "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/find-mggraphcommand?view=graph-powershell-1.0" + Uri = $null + } + # Update the file + $FinalFindOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 + + $FinalFindOutPut | Set-Content -Path $CommandMetadataFile -Force + Write-Host "Find-MgGraphCommand command added to the list of commands in MgCommandMetadata.json" +} +# Check if Find-MgGraphPermission is in the list of commands +$FindPermissionCommand = $CommandMetadata | Where-Object { $_.Name -eq "Find-MgGraphPermission" } +if ($null -eq $FindPermissionCommand) { + #Add Find-MgGraphPermission to the list of commands + $CommandMetadata += [pscustomobject]@{ + Command = "Find-MgGraphPermission" + Method = $null + Module = "Authentication" + CommandAlias = $null + Permissions = @() + ApiVersion = $null + OutputType = "System.Array" + Variants = @() + ApiReferenceLink = "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/find-mggraphpermission?view=graph-powershell-1.0" + Uri = $null + } + # Update the file + $FinalFindPermissionOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 + + $FinalFindPermissionOutPut | Set-Content -Path $CommandMetadataFile -Force + Write-Host "Find-MgGraphPermission command added to the list of commands in MgCommandMetadata.json" +} +#Check if Get-MgContext is in the list of commands +$GetContextCommand = $CommandMetadata | Where-Object { $_.Name -eq "Get-MgContext" } +if ($null -eq $GetContextCommand) { + #Add Get-MgContext to the list of commands + $CommandMetadata += [pscustomobject]@{ + Command = "Get-MgContext" + Method = $null + Module = "Authentication" + CommandAlias = $null + Permissions = @() + ApiVersion = $null + OutputType = "Microsoft.Graph.PowerShell.Authentication.IAuthContext" + Variants = @() + ApiReferenceLink = "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/get-mgcontext?view=graph-powershell-1.0" + Uri = $null + } + # Update the file + $FinalGetContextOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 + + $FinalGetContextOutPut | Set-Content -Path $CommandMetadataFile -Force + Write-Host "Get-MgContext command added to the list of commands in MgCommandMetadata.json" +} +#Check if Get-MgGraphOption is in the list of commands +$GetGraphOptionCommand = $CommandMetadata | Where-Object { $_.Name -eq "Get-MgGraphOption" } +if ($null -eq $GetGraphOptionCommand) { + #Add Get-MgGraphOption to the list of commands + $CommandMetadata += [pscustomobject]@{ + Command = "Get-MgGraphOption" + Method = $null + Module = "Authentication" + CommandAlias = $null + Permissions = @() + ApiVersion = $null + OutputType = "Microsoft.Graph.PowerShell.Authentication.IGraphOption" + Variants = @() + ApiReferenceLink = "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/get-mggraphoption?view=graph-powershell-1.0" + Uri = $null + } + # Update the file + $FinalGetGraphOptionOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 + + $FinalGetGraphOptionOutPut | Set-Content -Path $CommandMetadataFile -Force + Write-Host "Get-MgGraphOption command added to the list of commands in MgCommandMetadata.json" +} +#Check if Get-MgRequestContext is in the list of commands +$GetRequestContextCommand = $CommandMetadata | Where-Object { $_.Name -eq "Get-MgRequestContext" } +if ($null -eq $GetRequestContextCommand) { + #Add Get-MgRequestContext to the list of commands + $CommandMetadata += [pscustomobject]@{ + Command = "Get-MgRequestContext" + Method = $null + Module = "Authentication" + CommandAlias = $null + Permissions = @() + ApiVersion = $null + OutputType = "Microsoft.Graph.PowerShell.Authentication.Core.Interfaces.IRequestContext" + Variants = @() + ApiReferenceLink = "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/get-mgrequestcontext?view=graph-powershell-1.0" + Uri = $null + } + # Update the file + $FinalGetRequestContextOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 + + $FinalGetRequestContextOutPut | Set-Content -Path $CommandMetadataFile -Force + Write-Host "Get-MgRequestContext command added to the list of commands in MgCommandMetadata.json" +} +#Check if Invoke-MgGraphRequest is in the list of commands +$InvokeRequestCommand = $CommandMetadata | Where-Object { $_.Name -eq "Invoke-MgGraphRequest" } +if ($null -eq $InvokeRequestCommand) { + #Add Invoke-MgGraphRequest to the list of commands + $CommandMetadata += [pscustomobject]@{ + Command = "Invoke-MgGraphRequest" + Method = $null + Module = "Authentication" + CommandAlias = $null + Permissions = @() + ApiVersion = $null + OutputType = "System.Object" + Variants = @() + ApiReferenceLink = "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/invoke-mggraphrequest?view=graph-powershell-1.0" + Uri = $null + } + # Update the file + $FinalInvokeRequestOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 + + $FinalInvokeRequestOutPut | Set-Content -Path $CommandMetadataFile -Force + Write-Host "Invoke-MgGraphRequest command added to the list of commands in MgCommandMetadata.json" +} +#Check if Set-MgGraphOption is in the list of commands +$SetGraphOptionCommand = $CommandMetadata | Where-Object { $_.Name -eq "Set-MgGraphOption" } +if ($null -eq $SetGraphOptionCommand) { + #Add Set-MgGraphOption to the list of commands + $CommandMetadata += [pscustomobject]@{ + Command = "Set-MgGraphOption" + Method = $null + Module = "Authentication" + CommandAlias = $null + Permissions = @() + ApiVersion = $null + OutputType = "System.Object" + Variants = @() + ApiReferenceLink = "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/set-mggraphoption?view=graph-powershell-1.0" + Uri = $null + } + # Update the file + $FinalSetGraphOptionOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 + + $FinalSetGraphOptionOutPut | Set-Content -Path $CommandMetadataFile -Force + Write-Host "Set-MgGraphOption command added to the list of commands in MgCommandMetadata.json" +} +#Check if Set-MgRequestContext is in the list of commands +$SetRequestContextCommand = $CommandMetadata | Where-Object { $_.Name -eq "Set-MgRequestContext" } +if ($null -eq $SetRequestContextCommand) { + #Add Set-MgRequestContext to the list of commands + $CommandMetadata += [pscustomobject]@{ + Command = "Set-MgRequestContext" + Method = $null + Module = "Authentication" + CommandAlias = $null + Permissions = @() + ApiVersion = $null + OutputType = "Microsoft.Graph.PowerShell.Authentication.Core.Interfaces.IRequestContext" + Variants = @() + ApiReferenceLink = "https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/set-mgrequestcontext?view=graph-powershell-1.0" + Uri = $null + } + # Update the file + $FinalSetRequestContextOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 + + $FinalSetRequestContextOutPut | Set-Content -Path $CommandMetadataFile -Force + Write-Host "Set-MgRequestContext command added to the list of commands in MgCommandMetadata.json" +} + From c16103acd99b5a4d203cfff47a12ad025175a0d5 Mon Sep 17 00:00:00 2001 From: Microsoft Graph DevX Tooling Date: Tue, 1 Apr 2025 11:20:37 +0300 Subject: [PATCH 2/3] Moved script to postgeneration folder --- .../generate-command-metadata.yml | 8 +++++ .../AuthModuleMetadata.ps1 | 30 +++++++++---------- 2 files changed, 23 insertions(+), 15 deletions(-) rename tools/{ => PostGeneration}/AuthModuleMetadata.ps1 (91%) diff --git a/.azure-pipelines/generation-templates/generate-command-metadata.yml b/.azure-pipelines/generation-templates/generate-command-metadata.yml index fcd77c1dcdd..c37cb5f84bb 100644 --- a/.azure-pipelines/generation-templates/generate-command-metadata.yml +++ b/.azure-pipelines/generation-templates/generate-command-metadata.yml @@ -9,6 +9,14 @@ steps: pwsh: true script: | . $(System.DefaultWorkingDirectory)/tools/PostGeneration/NewCommandMetadata.ps1 -SourcePath "$(System.DefaultWorkingDirectory)/src/" -IncludePermissions -Debug + - task: PowerShell@2 + - task: PowerShell@2 + displayName: Generate authentication module metadata + inputs: + targetType: inline + pwsh: true + script: | + . $(System.DefaultWorkingDirectory)/tools/PostGeneration/AuthModuleMetadata.ps1 - task: Bash@3 displayName: Push command metadata diff --git a/tools/AuthModuleMetadata.ps1 b/tools/PostGeneration/AuthModuleMetadata.ps1 similarity index 91% rename from tools/AuthModuleMetadata.ps1 rename to tools/PostGeneration/AuthModuleMetadata.ps1 index 18d700d4e25..835fc7dc620 100644 --- a/tools/AuthModuleMetadata.ps1 +++ b/tools/PostGeneration/AuthModuleMetadata.ps1 @@ -1,10 +1,10 @@ #Load MgCommandMetadata.json file -$CommandMetadataFile = (Join-Path $PSScriptRoot "../src\Authentication/Authentication/custom/common/MgCommandMetadata.json") +$CommandMetadataFile = (Join-Path $PSScriptRoot "..\..\src\Authentication\Authentication\custom\common\MgCommandMetadata.json") #Convert JSON to HashTable $CommandMetadata = Get-Content $CommandMetadataFile | ConvertFrom-Json -AsHashTable #Check if Connect-MgGraph is in the list of commands -$ConnectCommand = $CommandMetadata | Where-Object { $_.Name -eq "Connect-MgGraph" } +$ConnectCommand = $CommandMetadata | Where-Object { $_.Command -eq "Connect-MgGraph" } if ($null -eq $ConnectCommand) { #Add Connect-MgGraph to the list of commands $CommandMetadata += [pscustomobject]@{ @@ -27,7 +27,7 @@ if ($null -eq $ConnectCommand) { } #Check if Add-MgEnvironment is in the list of commands -$AddEnvironmentCommand = $CommandMetadata | Where-Object { $_.Name -eq "Add-MgEnvironment" } +$AddEnvironmentCommand = $CommandMetadata | Where-Object { $_.Command -eq "Add-MgEnvironment" } if ($null -eq $AddEnvironmentCommand) { #Add Add-MgEnvironment to the list of commands $CommandMetadata += [pscustomobject]@{ @@ -49,7 +49,7 @@ if ($null -eq $AddEnvironmentCommand) { Write-Host "Add-MgEnvironment command added to the list of commands in MgCommandMetadata.json" } #Check if Get-MgEnvironment is in the list of commands -$GetEnvironmentCommand = $CommandMetadata | Where-Object { $_.Name -eq "Get-MgEnvironment" } +$GetEnvironmentCommand = $CommandMetadata | Where-Object { $_.Command -eq "Get-MgEnvironment" } if ($null -eq $GetEnvironmentCommand) { #Add Get-MgEnvironment to the list of commands $CommandMetadata += [pscustomobject]@{ @@ -71,7 +71,7 @@ if ($null -eq $GetEnvironmentCommand) { Write-Host "Get-MgEnvironment command added to the list of commands in MgCommandMetadata.json" } #Check if Remove-MgEnvironment is in the list of commands -$RemoveEnvironmentCommand = $CommandMetadata | Where-Object { $_.Name -eq "Remove-MgEnvironment" } +$RemoveEnvironmentCommand = $CommandMetadata | Where-Object { $_.Command -eq "Remove-MgEnvironment" } if ($null -eq $RemoveEnvironmentCommand) { #Add Remove-MgEnvironment to the list of commands $CommandMetadata += [pscustomobject]@{ @@ -93,7 +93,7 @@ if ($null -eq $RemoveEnvironmentCommand) { Write-Host "Remove-MgEnvironment command added to the list of commands in MgCommandMetadata.json" } #Check if Set-MgEnvironment is in the list of commands -$SetEnvironmentCommand = $CommandMetadata | Where-Object { $_.Name -eq "Set-MgEnvironment" } +$SetEnvironmentCommand = $CommandMetadata | Where-Object { $_.Command -eq "Set-MgEnvironment" } if ($null -eq $SetEnvironmentCommand) { #Add Set-MgEnvironment to the list of commands $CommandMetadata += [pscustomobject]@{ @@ -115,7 +115,7 @@ if ($null -eq $SetEnvironmentCommand) { Write-Host "Set-MgEnvironment command added to the list of commands in MgCommandMetadata.json" } #Check if Disconnect-MgGraph is in the list of commands -$DisconnectCommand = $CommandMetadata | Where-Object { $_.Name -eq "Disconnect-MgGraph" } +$DisconnectCommand = $CommandMetadata | Where-Object { $_.Command -eq "Disconnect-MgGraph" } if ($null -eq $DisconnectCommand) { #Add Disconnect-MgGraph to the list of commands $CommandMetadata += [pscustomobject]@{ @@ -137,7 +137,7 @@ if ($null -eq $DisconnectCommand) { Write-Host "Disconnect-MgGraph command added to the list of commands in MgCommandMetadata.json" } #Check if Find-MgGraphCommand is in the list of commands -$FindCommand = $CommandMetadata | Where-Object { $_.Name -eq "Find-MgGraphCommand" } +$FindCommand = $CommandMetadata | Where-Object { $_.Command -eq "Find-MgGraphCommand" } if ($null -eq $FindCommand) { #Add Find-MgGraphCommand to the list of commands $CommandMetadata += [pscustomobject]@{ @@ -159,7 +159,7 @@ if ($null -eq $FindCommand) { Write-Host "Find-MgGraphCommand command added to the list of commands in MgCommandMetadata.json" } # Check if Find-MgGraphPermission is in the list of commands -$FindPermissionCommand = $CommandMetadata | Where-Object { $_.Name -eq "Find-MgGraphPermission" } +$FindPermissionCommand = $CommandMetadata | Where-Object { $_.Command -eq "Find-MgGraphPermission" } if ($null -eq $FindPermissionCommand) { #Add Find-MgGraphPermission to the list of commands $CommandMetadata += [pscustomobject]@{ @@ -181,7 +181,7 @@ if ($null -eq $FindPermissionCommand) { Write-Host "Find-MgGraphPermission command added to the list of commands in MgCommandMetadata.json" } #Check if Get-MgContext is in the list of commands -$GetContextCommand = $CommandMetadata | Where-Object { $_.Name -eq "Get-MgContext" } +$GetContextCommand = $CommandMetadata | Where-Object { $_.Command -eq "Get-MgContext" } if ($null -eq $GetContextCommand) { #Add Get-MgContext to the list of commands $CommandMetadata += [pscustomobject]@{ @@ -203,7 +203,7 @@ if ($null -eq $GetContextCommand) { Write-Host "Get-MgContext command added to the list of commands in MgCommandMetadata.json" } #Check if Get-MgGraphOption is in the list of commands -$GetGraphOptionCommand = $CommandMetadata | Where-Object { $_.Name -eq "Get-MgGraphOption" } +$GetGraphOptionCommand = $CommandMetadata | Where-Object { $_.Command -eq "Get-MgGraphOption" } if ($null -eq $GetGraphOptionCommand) { #Add Get-MgGraphOption to the list of commands $CommandMetadata += [pscustomobject]@{ @@ -225,7 +225,7 @@ if ($null -eq $GetGraphOptionCommand) { Write-Host "Get-MgGraphOption command added to the list of commands in MgCommandMetadata.json" } #Check if Get-MgRequestContext is in the list of commands -$GetRequestContextCommand = $CommandMetadata | Where-Object { $_.Name -eq "Get-MgRequestContext" } +$GetRequestContextCommand = $CommandMetadata | Where-Object { $_.Command -eq "Get-MgRequestContext" } if ($null -eq $GetRequestContextCommand) { #Add Get-MgRequestContext to the list of commands $CommandMetadata += [pscustomobject]@{ @@ -247,7 +247,7 @@ if ($null -eq $GetRequestContextCommand) { Write-Host "Get-MgRequestContext command added to the list of commands in MgCommandMetadata.json" } #Check if Invoke-MgGraphRequest is in the list of commands -$InvokeRequestCommand = $CommandMetadata | Where-Object { $_.Name -eq "Invoke-MgGraphRequest" } +$InvokeRequestCommand = $CommandMetadata | Where-Object { $_.Command -eq "Invoke-MgGraphRequest" } if ($null -eq $InvokeRequestCommand) { #Add Invoke-MgGraphRequest to the list of commands $CommandMetadata += [pscustomobject]@{ @@ -269,7 +269,7 @@ if ($null -eq $InvokeRequestCommand) { Write-Host "Invoke-MgGraphRequest command added to the list of commands in MgCommandMetadata.json" } #Check if Set-MgGraphOption is in the list of commands -$SetGraphOptionCommand = $CommandMetadata | Where-Object { $_.Name -eq "Set-MgGraphOption" } +$SetGraphOptionCommand = $CommandMetadata | Where-Object { $_.Command -eq "Set-MgGraphOption" } if ($null -eq $SetGraphOptionCommand) { #Add Set-MgGraphOption to the list of commands $CommandMetadata += [pscustomobject]@{ @@ -291,7 +291,7 @@ if ($null -eq $SetGraphOptionCommand) { Write-Host "Set-MgGraphOption command added to the list of commands in MgCommandMetadata.json" } #Check if Set-MgRequestContext is in the list of commands -$SetRequestContextCommand = $CommandMetadata | Where-Object { $_.Name -eq "Set-MgRequestContext" } +$SetRequestContextCommand = $CommandMetadata | Where-Object { $_.Command -eq "Set-MgRequestContext" } if ($null -eq $SetRequestContextCommand) { #Add Set-MgRequestContext to the list of commands $CommandMetadata += [pscustomobject]@{ From 33ae41036d24c94f64a54a4052ceff8924ef7a0d Mon Sep 17 00:00:00 2001 From: Microsoft Graph DevX Tooling Date: Tue, 1 Apr 2025 11:36:38 +0300 Subject: [PATCH 3/3] Added metadata generation for auth module to workload-modules step --- .azure-pipelines/generation-templates/workload-modules.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.azure-pipelines/generation-templates/workload-modules.yml b/.azure-pipelines/generation-templates/workload-modules.yml index 0383f28baf1..b8fd4e86a5c 100644 --- a/.azure-pipelines/generation-templates/workload-modules.yml +++ b/.azure-pipelines/generation-templates/workload-modules.yml @@ -39,6 +39,13 @@ steps: pwsh: true script: | . $(System.DefaultWorkingDirectory)/tools/PostGeneration/FindDuplicateCommand.ps1 -SourcePath "$(System.DefaultWorkingDirectory)/src/" + - task: PowerShell@2 + displayName: Generate authentication module metadata + inputs: + targetType: inline + pwsh: true + script: | + . $(System.DefaultWorkingDirectory)/tools/PostGeneration/AuthModuleMetadata.ps1 - ${{ if eq(parameters.Sign, true) }}: - template: ../common-templates/esrp/strongname.yml