From cb82fd51bdacae87fc9e259932a8cae785c8bc54 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Tue, 5 Sep 2023 13:33:21 -0700 Subject: [PATCH] chore: Resolve duplicate command in Users.Functions --- .../generation-templates/workload-modules.yml | 8 ++++++++ src/Users.Functions/Users.Functions.md | 4 ++-- tools/PostGeneration/FindDuplicateCommand.ps1 | 8 ++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.azure-pipelines/generation-templates/workload-modules.yml b/.azure-pipelines/generation-templates/workload-modules.yml index 285d4d7c092..98057eab521 100644 --- a/.azure-pipelines/generation-templates/workload-modules.yml +++ b/.azure-pipelines/generation-templates/workload-modules.yml @@ -30,6 +30,14 @@ steps: script: | . $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -SkipGeneration -Test + - task: PowerShell@2 + displayName: Find Duplicate Commands + inputs: + targetType: inline + pwsh: true + script: | + . $(System.DefaultWorkingDirectory)/tools/PostGeneration/FindDuplicateCommand.ps1 -SourcePath "$(System.DefaultWorkingDirectory)/src/" + - ${{ if eq(parameters.Sign, true) }}: - template: ../common-templates/esrp/strongname.yml parameters: diff --git a/src/Users.Functions/Users.Functions.md b/src/Users.Functions/Users.Functions.md index 3dac42ae46d..8d636adc3e3 100644 --- a/src/Users.Functions/Users.Functions.md +++ b/src/Users.Functions/Users.Functions.md @@ -32,7 +32,7 @@ directive: subject: $1AllowedCalendarSharingRoles - where: verb: Get - subject: ^(UserChatMessage)$ + subject: ^(User)(ChatMessage|OnlineMeetingTranscript|OnlineMeetingRecording)$ set: - subject: All$1 + subject: All$1$2 ``` diff --git a/tools/PostGeneration/FindDuplicateCommand.ps1 b/tools/PostGeneration/FindDuplicateCommand.ps1 index d75191aa6b7..d1938a6a9ba 100644 --- a/tools/PostGeneration/FindDuplicateCommand.ps1 +++ b/tools/PostGeneration/FindDuplicateCommand.ps1 @@ -15,17 +15,17 @@ if (!(Test-Path $SourcePath)) { Write-Error "SourcePath is not valid or does not exist. Please ensure that $SourcePath exists then try again." } -$psd1s = Get-ChildItem -Path $SourcePath -Filter "Microsoft.Graph.*.psd1" -Recurse | where { $_.BaseName -ne "Microsoft.Graph.Authentication" } -$allModules = (Invoke-Expression (($psd1s.FullName | ForEach-Object{ Get-Content $_}) | Out-String )) +$psd1s = Get-ChildItem -Path $SourcePath -Filter "Microsoft.Graph.*.psd1" -Recurse | Where-Object { $_.BaseName -ne "Microsoft.Graph.Authentication" } +$allModules = Import-PowerShellDataFile $psd1s.FullName $unique = $allModules.FunctionsToExport | Select-Object -unique $duplicates = Compare-object -ReferenceObject $unique -DifferenceObject $allModules.FunctionsToExport if ($duplicates.Count -gt 0) { Write-Host "The following functions are duplicated in the psd1 files:" - $duplicates.InputObject | %{ + $duplicates.InputObject | ForEach-Object { $duplicateCommand = $_ Write-Host "$duplicateCommand is duplicated in:" - Write-Host ($allModules | where { $_.FunctionsToExport -contains $duplicateCommand }).RootModule + Write-Host ($allModules | Where-Object { $_.FunctionsToExport -contains $duplicateCommand }).RootModule Write-Host "********************************" } Write-Error "Please ensure that the functions are unique and try again."