Skip to content

Commit f77f57b

Browse files
Merge branch 'main' into enganga/Update-EntraInvitedUserSponsorsFromInvitedBy
2 parents af0ab89 + a8872f2 commit f77f57b

File tree

142 files changed

+1444
-619
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+1444
-619
lines changed

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
blank_issues_enabled: true
2+
contact_links:
3+
- name: Questions & Discussions 💬
4+
url: https://github.com/microsoftgraph/entra-powershell/discussions
5+
about: Please use GitHub discussions for any questions or ideas.
6+
- name: Documentation 📖
7+
url: https://aka.ms/entra/ps/docs
8+
about: Microsoft Entra PowerShell documentation
9+
- name: Known Issues ⚠️
10+
url: https://github.com/microsoftgraph/entra-powershell?tab=readme-ov-file#known-issues
Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
---
22
name: Entra PowerShell bug report
3-
about: Create a bug report to help us fix it
4-
title: ''
3+
about: Create a bug report to help us fix it.
4+
title: '🪲 '
55
labels: ''
66
assignees: ''
77

88
---
9+
<!--- Provide a general summary of the issue in the Title above -->
910

11+
<!-- markdownlint-disable MD033 -->
1012
Thanks for reporting the bug. Please ensure you've gone through the following checklist before opening an issue:
1113

1214
- Make sure you can reproduce this issue using the latest released version of `Microsoft.Entra` or `Microsoft.Entra.Beta`.
1315
- Please search the existing issues to see if there has been a similar issue filed.
1416

1517
## Describe the bug
16-
17-
> A clear and concise description of what the bug is.
18+
<!-- 📝 Please provide a clear and concise description of what the bug is. -->
1819

1920
## To Reproduce
2021

@@ -24,27 +25,28 @@ Steps to reproduce the behavior:
2425
2. See error at `...`
2526

2627
## Expected behavior
27-
28-
> A clear and concise description of what you expected to happen.
28+
<!-- 📝 Please give a clear and concise description of what you expected to happen. -->
2929

3030
## Debug Output
31+
<!-- 🔬 Run the problematic command with `-Debug` and paste the resulting debug stream below. -->
32+
⚠ ATTENTION: Be sure to remove any sensitive information that may be in the logs.
3133

32-
> Run the problematic command with `-Debug` and paste the resulting debug stream below.
33-
> ⚠ ATTENTION: Be sure to remove any sensitive information that may be in the logs.
34+
<details>
35+
<summary>Debug Output</summary>
36+
<!-- Please paste the debug output here. 👇 -->
37+
</details>
3438

3539
## Module Version
36-
37-
> Please run `Get-Module Microsoft.Entra*` after cmdlet execution and paste the output below.
38-
> If a module cannot be installed or imported, please run `Get-Module -ListAvailable` and paste the output.
40+
<!-- 📦 Please run `Get-Module -Name "Microsoft*Entra*` after cmdlet execution and paste the output below.
41+
If a module cannot be installed or imported, please run `Get-Module -ListAvailable` and paste the output. -->
3942

4043
## Environment Data
41-
42-
> Please run `$PSVersionTable` and paste the output below. If running the Docker container image, indicate the tag of the image used and the version of Docker engine.
44+
<!-- 🖥️ Please run `$PSVersionTable` and paste the output below. If running the Docker container image, indicate the tag of the image used and the version of Docker engine. -->
4345

4446
## Screenshots
45-
46-
> If applicable, add screenshots to help explain your problem.
47+
<!-- 📸 If applicable, add screenshots to help explain your problem. -->
4748

4849
## Additional context
50+
<!-- 💡 Add any other context about the problem here. -->
4951

50-
> Add any other context about the problem here.
52+
<!-- 🤝 Thank you for taking the time to submit this report! -->
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
---
2-
name: Feature request
3-
about: Suggest an idea for this project
4-
title: ''
5-
labels: ''
2+
name: Entra PowerShell feature request
3+
about: Suggest an idea for this project.
4+
title: '🙏 '
5+
labels: 'Feature'
66
assignees: ''
77

88
---
9+
<!--- Provide a general summary of the feature request in the Title above -->
910

10-
**Describe the feature**
11-
A clear and concise description of this feature. Please describe what the feature does. You’ll be asked why it is important later.
11+
## Describe the feature
12+
<!-- 📝 A clear and concise description of this feature. Please describe what the feature does. You’ll be asked why it is important later. -->
1213

1314
**How will this feature enhance your project and further the project’s overall goals? Who will benefit from this feature (i.e. all users; the project team)?**
14-
A concise statement about the importance of the feature and the impact it should have on your project.
15+
<!-- 🥅 A concise statement about the importance of the feature and the impact it should have on your project. -->
1516

1617
**Describe alternatives you've considered**
17-
A clear and concise description of any alternative solutions or features you've considered.
18+
<!-- 📝 A clear and concise description of any alternative solutions or features you've considered. -->
1819

19-
**Additional context**
20-
Add any other context or screenshots about the feature request here.
20+
### Additional context
21+
<!-- 💡 Add any other context or screenshots about the feature request here. -->

1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# ------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All Rights Reserved.
3+
# Licensed under the MIT License. See License in the project root for license information.
4+
# ------------------------------------------------------------------------------
5+
function Resolve-EntraTenant {
6+
[CmdletBinding(
7+
DefaultParameterSetName = 'TenantId',
8+
SupportsShouldProcess = $false,
9+
PositionalBinding = $false,
10+
HelpUri = 'https://learn.microsoft.com/',
11+
ConfirmImpact = 'Medium'
12+
)]
13+
[Alias()]
14+
[OutputType([PSCustomObject])]
15+
Param (
16+
# The TenantId in GUID format (supports multiple values)
17+
[Parameter(
18+
ParameterSetName = 'TenantId',
19+
Mandatory = $true,
20+
Position = 0,
21+
ValueFromPipeline = $true,
22+
ValueFromPipelineByPropertyName = $true,
23+
HelpMessage = "Unique Id(s) of the Tenant(s) in GUID format."
24+
)]
25+
[ValidateScript({ $_ -match "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$" })]
26+
[string[]]
27+
$TenantId,
28+
29+
# The TenantDomainName in DNS Name format (supports multiple values)
30+
[Parameter(
31+
ParameterSetName = 'DomainName',
32+
Mandatory = $true,
33+
Position = 0,
34+
ValueFromPipeline = $true,
35+
ValueFromPipelineByPropertyName = $true,
36+
HelpMessage = "Unique Domain Name(s) of the Tenant(s) (e.g., contoso.com)."
37+
)]
38+
[ValidateScript({ $_ -match "^(?!-)[A-Za-z0-9-]{1,63}(?<!-)(\.[A-Za-z]{2,})+$" })]
39+
[string[]]
40+
$DomainName,
41+
42+
# Environment to resolve Azure AD Tenant
43+
[Parameter(
44+
Mandatory = $false,
45+
Position = 1,
46+
ValueFromPipeline = $true,
47+
ValueFromPipelineByPropertyName = $true,
48+
HelpMessage = "Tenant Environment Name (Global, USGov, China, USGovDoD, Germany)."
49+
)]
50+
[ValidateSet("Global", "USGov", "China", "USGovDoD", "Germany")]
51+
[string]
52+
$Environment = "Global",
53+
54+
# Skip resolving via the OIDC Metadata endpoint
55+
[Parameter(Mandatory=$false, HelpMessage="Specify whether to skip resolving via the OIDC metadata endpoint.")]
56+
[switch]
57+
$SkipOidcMetadataEndpoint
58+
)
59+
60+
begin {
61+
# Retrieve endpoint information based on the environment
62+
$graphEndpoint = (Get-EntraEnvironment -Name $Environment).GraphEndpoint
63+
$azureAdEndpoint = (Get-EntraEnvironment -Name $Environment).AzureAdEndpoint
64+
65+
Write-Verbose ("Using $Environment login endpoint: $azureAdEndpoint")
66+
Write-Verbose ("Using $Environment Graph endpoint: $graphEndpoint")
67+
}
68+
69+
process {
70+
$itemsToProcess = if ($TenantId) { $TenantId } else { $DomainName }
71+
72+
foreach ($item in $itemsToProcess) {
73+
# Initialize headers and result object
74+
$customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand
75+
$resolveUri = $null
76+
$resolvedTenant = [ordered]@{
77+
Environment = $Environment
78+
}
79+
80+
# Set URI based on parameter set
81+
if ($PSCmdlet.ParameterSetName -eq 'TenantId') {
82+
Write-Verbose ("Resolving Azure AD Tenant by TenantId: $item")
83+
$resolveUri = "$graphEndpoint/v1.0/tenantRelationships/findTenantInformationByTenantId(tenantId='$item')"
84+
$resolvedTenant.ValueFormat = "TenantId"
85+
}
86+
elseif ($PSCmdlet.ParameterSetName -eq 'DomainName') {
87+
Write-Verbose ("Resolving Azure AD Tenant by DomainName: $item")
88+
$resolveUri = "$graphEndpoint/v1.0/tenantRelationships/findTenantInformationByDomainName(domainName='$item')"
89+
$resolvedTenant.ValueFormat = "DomainName"
90+
}
91+
92+
if ($resolveUri) {
93+
try {
94+
Write-Verbose ("Resolving Tenant Information using MS Graph API.")
95+
$resolve = Invoke-MgGraphRequest -Method Get -Uri $resolveUri -ErrorAction Stop -Headers $customHeaders |
96+
Select-Object tenantId, displayName, defaultDomainName, federationBrandName
97+
98+
# Populate resolved tenant details
99+
$resolvedTenant.Result = "Resolved"
100+
$resolvedTenant.ResultMessage = "Tenant resolved successfully."
101+
$resolvedTenant.TenantId = $resolve.tenantId
102+
$resolvedTenant.DisplayName = $resolve.displayName
103+
$resolvedTenant.DefaultDomainName = $resolve.defaultDomainName
104+
$resolvedTenant.FederationBrandName = $resolve.federationBrandName
105+
}
106+
catch {
107+
$resolvedTenant.Result = "Error"
108+
$resolvedTenant.ResultMessage = $_.Exception.Message
109+
$resolvedTenant.TenantId = $null
110+
$resolvedTenant.DisplayName = $null
111+
$resolvedTenant.DefaultDomainName = $null
112+
$resolvedTenant.FederationBrandName = $null
113+
}
114+
}
115+
116+
# Handle OIDC Metadata endpoint resolution
117+
if (-not $SkipOidcMetadataEndpoint) {
118+
$oidcMetadataUri = "$azureAdEndpoint/$item/v2.0/.well-known/openid-configuration"
119+
120+
try {
121+
$oidcMetadata = Invoke-RestMethod -Method Get -Uri $oidcMetadataUri -ErrorAction Stop -Headers $customHeaders
122+
$resolvedTenant.OidcMetadataResult = "Resolved"
123+
$resolvedTenant.OidcMetadataTenantId = $oidcMetadata.issuer.split("/")[3]
124+
$resolvedTenant.OidcMetadataTenantRegionScope = $oidcMetadata.tenant_region_scope
125+
}
126+
catch {
127+
$resolvedTenant.OidcMetadataResult = "Not Found"
128+
$resolvedTenant.OidcMetadataTenantId = $null
129+
$resolvedTenant.OidcMetadataTenantRegionScope = $null
130+
}
131+
}
132+
else {
133+
$resolvedTenant.OidcMetadataResult = "Skipped"
134+
}
135+
136+
Write-Output ([PSCustomObject]$resolvedTenant)
137+
}
138+
}
139+
}

module/Entra/config/ModuleMetadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"Windows"
3939
],
4040
"releaseNotes": "See https://github.com/microsoftgraph/entra-powershell.",
41-
"version": "1.0.1",
41+
"version": "1.0.2",
4242
"Prerelease": "",
4343
"dotNetVersion": "4.7.2",
4444
"powershellVersion": "5.1"
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# ------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All Rights Reserved.
3+
# Licensed under the MIT License. See License in the project root for license information.
4+
# ------------------------------------------------------------------------------
5+
function Get-EntraEnvironment{
6+
[CmdletBinding(DefaultParameterSetName = 'GetQuery')]
7+
param (
8+
[Parameter(ParameterSetName = "GetQuery", Mandatory = $false, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
9+
[System.String] $Name)
10+
PROCESS{
11+
$params = @{}
12+
if ($PSBoundParameters.ContainsKey("Verbose")) {
13+
$params["Verbose"] = $PSBoundParameters["Verbose"]
14+
}
15+
if ($PSBoundParameters.ContainsKey("Debug")) {
16+
$params["Debug"] = $PSBoundParameters["Debug"]
17+
}
18+
if($null -ne $PSBoundParameters["WarningVariable"])
19+
{
20+
$params["WarningVariable"] = $PSBoundParameters["WarningVariable"]
21+
}
22+
if($null -ne $PSBoundParameters["InformationVariable"])
23+
{
24+
$params["InformationVariable"] = $PSBoundParameters["InformationVariable"]
25+
}
26+
if($null -ne $PSBoundParameters["InformationAction"])
27+
{
28+
$params["InformationAction"] = $PSBoundParameters["InformationAction"]
29+
}
30+
if($null -ne $PSBoundParameters["OutVariable"])
31+
{
32+
$params["OutVariable"] = $PSBoundParameters["OutVariable"]
33+
}
34+
if($null -ne $PSBoundParameters["OutBuffer"])
35+
{
36+
$params["OutBuffer"] = $PSBoundParameters["OutBuffer"]
37+
}
38+
if($null -ne $PSBoundParameters["ErrorVariable"])
39+
{
40+
$params["ErrorVariable"] = $PSBoundParameters["ErrorVariable"]
41+
}
42+
if($null -ne $PSBoundParameters["PipelineVariable"])
43+
{
44+
$params["PipelineVariable"] = $PSBoundParameters["PipelineVariable"]
45+
}
46+
if($null -ne $PSBoundParameters["ErrorAction"])
47+
{
48+
$params["ErrorAction"] = $PSBoundParameters["ErrorAction"]
49+
}
50+
if($null -ne $PSBoundParameters["WarningAction"])
51+
{
52+
$params["WarningAction"] = $PSBoundParameters["WarningAction"]
53+
}
54+
55+
if ($null -ne $PSBoundParameters["Name"]) {
56+
$params["Name"] = $PSBoundParameters["Name"]
57+
}
58+
59+
Write-Debug("============================ TRANSFORMATIONS ============================")
60+
$params.Keys | ForEach-Object { "$_ : $($params[$_])" } | Write-Debug
61+
Write-Debug("=========================================================================`n")
62+
63+
Get-MgEnvironment @params
64+
}
65+
}
66+
67+
68+

0 commit comments

Comments
 (0)