Skip to content

Conversation

@SamErde
Copy link
Contributor

@SamErde SamErde commented Apr 17, 2025

Fixed

⚠️ Fixes #1448: Cannot import Microsoft.Entra.Graph in Windows PowerShell 5.1 due to en dash being used in parameter HelpMessage text.

This PR replaces the en dashes with a regular hyphen. Successfully tested with a local build in Windows PowerShell 5.1 and PowerShell 7.5.

Changed

Additional automatic formatting and style updates based on standard conventions. Copilot summary:

  • Updated parameter help messages to use single quotes for consistency.
  • Changed parameter set names to use single quotes for consistency.
  • Improved formatting and alignment of parameter blocks in New-EntraGroup, Set-EntraGroup, New-EntraBetaGroup, and Set-EntraBetaGroup scripts.
  • Enhanced readability by standardizing the use of brackets and spacing in conditional statements.

Enhance: Additional automatic formatting and style  updates based on standard conventions.

- Updated parameter help messages to use single quotes for consistency.
- Changed parameter set names to use single quotes for consistency.
- Improved formatting and alignment of parameter blocks in New-EntraGroup, Set-EntraGroup, New-EntraBetaGroup, and Set-EntraBetaGroup scripts.
- Enhanced readability by standardizing the use of brackets and spacing in conditional statements.
@SamErde SamErde requested a review from a team as a code owner April 17, 2025 16:51
@learn-build-service-prod
Copy link

Learn Build status updates of commit b0a3415:

✅ Validation status: passed

File Status Preview URL Details
module/Entra/Microsoft.Entra/Groups/New-EntraGroup.ps1 ✅Succeeded
module/Entra/Microsoft.Entra/Groups/Set-EntraGroup.ps1 ✅Succeeded
module/EntraBeta/Microsoft.Entra.Beta/Groups/New-EntraBetaGroup.ps1 ✅Succeeded
module/EntraBeta/Microsoft.Entra.Beta/Groups/Set-EntraBetaGroup.ps1 ✅Succeeded

For more details, please refer to the build report.

For any questions, please:

@SamErde
Copy link
Contributor Author

SamErde commented Apr 17, 2025

I know it's late on the beginning of Easter weekend, but is anyone still available to review, merge, and publish this fix in a 1.6.1 release? Users on Windows PowerShell 5.1 currently cannot import Microsoft.Entra.Groups. 🙏 @DButoyez, @emmanuel-karanja, @KenitoInc, @SteveMutungi254, @v-akarke

Copy link
Contributor

@SteveMutungi254 SteveMutungi254 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@SteveMutungi254 SteveMutungi254 merged commit 66cd836 into microsoftgraph:main Apr 23, 2025
4 checks passed
@SamErde SamErde deleted the fix-groups-emdash branch April 23, 2025 11:38
@AngeloAgb
Copy link

Hi @SamErde , is this bug fixed for PowerShell 5.x?.
I suggested to my customer to use 7.x but she refused that they can't switch to 7.x due to dependency of other modules and automations they are running on 5.x.

Customer:
I am aware the module has been updated, and I have already modified the local build and using it.
Though MS has not published the module release yet with the fix. I am referring to the module release which has not been done yet. If you check PowerShell Gallery the last version is still 1.6.0. The fix has not been released.

@SamErde
Copy link
Contributor Author

SamErde commented Apr 28, 2025

Hi @SamErde , is this bug fixed for PowerShell 5.x?.

The fix has been merged into the project, but a new build has not been released yet. Your options for now are to either downgrade to v1.0.5 or to follow this repository's instructions to build a local copy of the module. (Not recommended unless you are familiar and comfortable with that process.)

@SteveMutungi254
Copy link
Contributor

SteveMutungi254 commented Apr 29, 2025

Update:

We’ve added PowerShell 5.1 validation "follow-up or repair item" to our build pipeline to catch these issues early and ensure they won’t happen again. Target ETA is by end of May. cc: @KenitoInc

@SteveMutungi254
Copy link
Contributor

SteveMutungi254 commented Apr 29, 2025

@AngeloAgb, @SamErde, the plan is to release a new version with the fixes by end of the week of 28th April to May 4th. cc: @DButoyez, @KenitoInc.

@AngeloAgb
Copy link

Hi @SamErde, @SteveMutungi254, @thomasvochten, the customer downgraded per your recommendation and still gets the error.
image

@SamErde
Copy link
Contributor Author

SamErde commented Apr 30, 2025

@AngeloAgb, can you please run Get-InstalledModule Microsoft.Entra* and share the output?

@SamErde
Copy link
Contributor Author

SamErde commented Apr 30, 2025

I suspect that you successfully downgraded the Microsoft.Entra module to 1.0.5, but v1.0.6 of the Entra sub-modules is probably also installed still. Running Get-InstalledModule Microsoft.Entra* should confirm that theory.

If so, there are two ways you can cleanly work around it:

Completely uninstall the base module and all sub-modules, and then re-install v1.0.5:

Get-InstalledModule Microsoft.Entra* | % { Uninstall-Module -Name $_.Name -AllVersions -Force }
# You MAY need to run the above command twice to make sure it's removed.
Install-Module -Name Microsoft.Entra -RequiredVersion 1.0.5
Import-Module -Name Microsoft.Entra

OR, import the older version explicitly and make sure Group 1.0.6 is not imported:

Import-Module Microsoft.Entra.Groups -RequiredVersion 1.0.5 -Force
Import-Module Microsoft.Entra
Get-Module | Where-Object {$_.Name -eq 'Microsoft.Entra.Groups' -and $_.Version -eq '1.0.6'} | Remove-Module -Force

It's not convenient, but it should work until the fix is released.

@AngeloAgb
Copy link

Hi @SamErde , here is an update from the customer.

That’s not the case here. I already removed all the modules before downgrading the Entra Module to 1.0.5.

image

After installing the module, the dependent modules which are installed automatically are always the latest one. If you try the steps on your end you will get what I am trying to explain.

@SamErde
Copy link
Contributor Author

SamErde commented Apr 30, 2025

OK, I updated my workaround example with more coverage. The following lines will ensure that both 1.0.5 and 1.0.6 are installed. It will successfully import the 1.0.5 Groups module and 1.0.6 of all other Microsoft.Entra modules. They will see the error still but the final output should show what they need:

# Run the following commands in a new PowerShell session before importing any modules:

# Install both versions of the module:
Install-Module -Name 'Microsoft.Entra' -RequiredVersion 1.0.5 -Force
Install-Module -Name 'Microsoft.Entra' -RequiredVersion 1.0.6 -Force

# Import the working version of the Groups sub-module:
Import-Module  -Name 'Microsoft.Entra.Groups' -RequiredVersion 1.0.5 -Force

# Import the base module and then remove the auto-imported version of the Groups sub-module that doesn't work:
Import-Module  -Name 'Microsoft.Entra'
Get-Module | Where-Object { $_.Name -eq 'Microsoft.Entra.Groups' -and $_.Version -eq '1.0.6' } | Remove-Module -Force

Here is what I get:

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

Loading personal and system profiles took 2290ms.
>> # Run the following commands in a new PowerShell session before importing any modules:
>>
>> # Install both versions of the module:
>> Install-Module -Name 'Microsoft.Entra' -RequiredVersion 1.0.5 -Force
>> Install-Module -Name 'Microsoft.Entra' -RequiredVersion 1.0.6 -Force
>>
>> # Import the working version of the Groups sub-module:
>> Import-Module  -Name 'Microsoft.Entra.Groups' -RequiredVersion 1.0.5 -Force
>>
>> # Import the base module and then remove the auto-imported version of the Groups sub-module that doesn't work:
>> Import-Module  -Name 'Microsoft.Entra'
Import-Module : At C:\Users\SamErde\OneDrive - Das
Erde\Documents\WindowsPowerShell\Modules\Microsoft.Entra.Groups\1.0.6\Microsoft.Entra.Groups.psm1:1302 char:191
+ ... group (max 64 characters). It must use ASCII characters (0–127).")]
+                                                                  ~
Missing closing ')' in expression.
At C:\Users\SamErde\OneDrive - Das
Erde\Documents\WindowsPowerShell\Modules\Microsoft.Entra.Groups\1.0.6\Microsoft.Entra.Groups.psm1:1302 char:191
+ ... group (max 64 characters). It must use ASCII characters (0–127).")]
+                                                                  ~
Parameter declarations are a comma-separated list of variable names with optional initializer expressions.
At C:\Users\SamErde\OneDrive - Das
Erde\Documents\WindowsPowerShell\Modules\Microsoft.Entra.Groups\1.0.6\Microsoft.Entra.Groups.psm1:1302 char:191
+ ... group (max 64 characters). It must use ASCII characters (0–127).")]
+                                                                  ~
Missing ')' in function parameter list.
At line:1 char:1
+ Import-Module  -Name 'Microsoft.Entra'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ParserError: (:) [Import-Module], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingEndParenthesisInExpression,Microsoft.PowerShell.Commands.ImportModuleCommand

>> Get-Module | Where-Object { $_.Name -eq 'Microsoft.Entra.Groups' -and $_.Version -eq '1.0.6' } | Remove-Module -Force
>> Get-Module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.0.6      Microsoft.Entra.Applications        {Add-EntraApplicationOwner, Add-EntraServicePrincipalDeleg...
Script     1.0.6      Microsoft.Entra.Authentication      {Add-EntraEnvironment, Connect-Entra, Disconnect-Entra, Fi...
Script     1.0.6      Microsoft.Entra.CertificateBased... {Get-EntraUserCBAAuthorizationInfo, Get-EntraUserCertifica...
Script     1.0.6      Microsoft.Entra.DirectoryManagement {Add-EntraAdministrativeUnitMember, Add-EntraCustomSecurit...
Script     1.0.6      Microsoft.Entra.Governance          {Get-EntraDirectoryRoleAssignment, Get-EntraDirectoryRoleD...
Script     1.0.5      Microsoft.Entra.Groups              {Add-EntraGroupMember, Add-EntraGroupOwner, Add-EntraLifec...
Script     2.25.0     Microsoft.Graph.Applications        {Add-MgApplicationKey, Add-MgApplicationPassword, Add-MgSe...
Script     2.25.0     Microsoft.Graph.Authentication      {Add-MgEnvironment, Connect-MgGraph, Disconnect-MgGraph, G...
Script     2.25.0     Microsoft.Graph.Groups              {Add-MgGroupDriveListContentTypeCopy, Add-MgGroupDriveList...
Script     2.25.0     Microsoft.Graph.Identity.Directo... {Confirm-MgContactMemberGroup, Confirm-MgContactMemberObje...
Script     2.25.0     Microsoft.Graph.Identity.Governance {Add-MgIdentityGovernanceAccessReviewDefinitionInstanceDec...
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con...
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Script     0.0        oh-my-posh-core                     {Enable-PoshLineError, Enable-PoshTooltips, Enable-PoshTra...
Script     1.4.8.1    PackageManagement                   {Find-Package, Find-PackageProvider, Get-Package, Get-Pack...
Script     1.1.0      posh-git                            {Add-PoshGitToProfile, Expand-GitCommand, Format-GitBranch...
Script     2.2.5      PowerShellGet                       {Find-Command, Find-DscResource, Find-Module, Find-RoleCap...
Script     2.3.6      PSReadLine                          {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PS...
Script     0.11.0     Terminal-Icons                      {Add-TerminalIconsColorTheme, Add-TerminalIconsIconTheme, ...

~/Code >

@AngeloAgb
Copy link

AngeloAgb commented May 5, 2025

Hello @SamErde @SteveMutungi254, thomasvochten, Just following up on this if the fix was successfully deployed on PS 5.x so I can ask the customer to test again.

You mentioned " there was a plan to deploy fixes by end of the week of 28th April to May 4th".

@SteveMutungi254
Copy link
Contributor

SteveMutungi254 commented May 5, 2025

@AngeloAgb - Yes, version 1.0.7 was successfully deployed on May 5th.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🪲 Microsoft.Entra.Groups.psm1 has a bug in version 1.0.6 preventing module load

3 participants