Skip to content

Commit 855d81b

Browse files
authored
Merge branch 'microsoftgraph:main' into se-Build-Install-Dependencies
2 parents e3368ff + 0029d93 commit 855d81b

File tree

1,354 files changed

+28684
-20056
lines changed

Some content is hidden

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

1,354 files changed

+28684
-20056
lines changed

.config/CredScanSuppressions.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@
4040
{
4141
"file": "test\\Entra\\Users\\New-EntraUser.Tests.ps1",
4242
"_justification": "Unit test file has a sample Password used in mocking."
43+
},
44+
{
45+
"file": "test\\EntraBeta\\Users\\New-EntraBetaUser.Tests.ps1",
46+
"_justification": "Unit test file has a sample Password used in mocking."
47+
},
48+
{
49+
"file": "test\\Entra\\CertificateBasedAuthentication\\Get-EntraUserCertificateUserIdsFromCertificate.Tests.ps1",
50+
"_justification": "Unit test file has a sample certificate with only public keys used in mocking."
4351
}
4452
]
4553
}

build/BUILD.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Import-Module .\bin\Microsoft.Entra.Applications.psd1 -Force
6060
Import-Module .\bin\Microsoft.Entra.DirectoryManagement.psd1 -Force
6161
Import-Module .\bin\Microsoft.Entra.Governance.psd1 -Force
6262
Import-Module .\bin\Microsoft.Entra.Users.psd1 -Force
63+
Import-Module .\bin\Microsoft.Entra.CertificateBasedAuthentication.psd1 -Force
6364
Import-Module .\bin\Microsoft.Entra.Groups.psd1 -Force
6465
Import-Module .\bin\Microsoft.Entra.Reports.psd1 -Force
6566
Import-Module .\bin\Microsoft.Entra.SignIns.psd1 -Force
@@ -138,6 +139,7 @@ Import-Module .\bin\Microsoft.Entra.Applications.psd1 -Force
138139
Import-Module .\bin\Microsoft.Entra.DirectoryManagement.psd1 -Force
139140
Import-Module .\bin\Microsoft.Entra.Governance.psd1 -Force
140141
Import-Module .\bin\Microsoft.Entra.Users.psd1 -Force
142+
Import-Module .\bin\Microsoft.Entra.CertificateBasedAuthentication.psd1 -Force
141143
Import-Module .\bin\Microsoft.Entra.Groups.psd1 -Force
142144
Import-Module .\bin\Microsoft.Entra.Reports.psd1 -Force
143145
Import-Module .\bin\Microsoft.Entra.SignIns.psd1 -Force

build/Create-EntraModule.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ param (
77

88
. (Join-Path $psscriptroot "/common-functions.ps1")
99
. (Join-Path $psscriptroot "../src/EntraModuleBuilder.ps1")
10+
. (Join-Path $psscriptroot "../src/Get-MissingCmds.ps1")
1011

1112
$moduleBuilder = [EntraModuleBuilder]::new()
1213

@@ -17,6 +18,7 @@ if($Module -eq 'Entra'){
1718
$typeDefsPath=(Join-Path $PSScriptRoot "/Beta-TypeDefs.txt")
1819
}
1920
if($Root){
21+
$moduleBuilder.CreateRootModule($Module)
2022
$moduleBuilder.CreateRootModuleManifest($Module)
2123
}else{
2224
$moduleBuilder.CreateModuleHelp($Module)

module/Entra/Microsoft.Entra/Applications/Add-EntraApplicationOwner.ps1

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,28 @@
33
# Licensed under the MIT License. See License in the project root for license information.
44
# ------------------------------------------------------------------------------
55
function Add-EntraApplicationOwner {
6-
[CmdletBinding(DefaultParameterSetName = '')]
6+
[CmdletBinding(DefaultParameterSetName = 'ByApplicationIdAndOwnerId')]
77
param (
88
[Alias('ObjectId')]
99
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Unique ID of the application object (Application Object ID).")]
10-
[System.String] $ApplicationId,
10+
[ValidateNotNullOrEmpty()]
11+
[guid] $ApplicationId,
1112

1213
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "The ID of the user, group, or service principal to be added as an owner of the application.")]
1314
[Alias('RefObjectId')]
14-
[System.String] $OwnerId
15+
[ValidateNotNullOrEmpty()]
16+
[guid] $OwnerId
1517
)
18+
19+
begin {
20+
# Ensure connection to Microsoft Entra
21+
if (-not (Get-EntraContext)) {
22+
$errorMessage = "Not connected to Microsoft Graph. Use 'Connect-Entra -Scopes Application.ReadWrite.All' to authenticate."
23+
Write-Error -Message $errorMessage -ErrorAction Stop
24+
return
25+
}
26+
}
27+
1628
PROCESS {
1729
$params = @{}
1830
$customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand
@@ -22,8 +34,18 @@ function Add-EntraApplicationOwner {
2234

2335
$newOwner = @{}
2436

37+
$rootUri = (Get-EntraEnvironment -Name (Get-EntraContext).Environment).GraphEndpoint
38+
39+
if (-not $rootUri) {
40+
$rootUri = "https://graph.microsoft.com"
41+
Write-Verbose "Using default Graph endpoint: $rootUri"
42+
}
43+
else {
44+
Write-Verbose "Using environment-specific Graph endpoint: $rootUri"
45+
}
46+
2547
if ($null -ne $PSBoundParameters["OwnerId"]) {
26-
$newOwner["@odata.id"] = "https://graph.microsoft.com/v1.0/directoryObjects/" + $PSBoundParameters["OwnerId"]
48+
$newOwner["@odata.id"] = "$rootUri/v1.0/directoryObjects/" + $PSBoundParameters["OwnerId"]
2749
$params["BodyParameter"] = $newOwner
2850
}
2951
if ($null -ne $PSBoundParameters["WarningVariable"]) {

module/Entra/Microsoft.Entra/Applications/Add-EntraServicePrincipalDelegatedPermissionClassification.ps1

Lines changed: 83 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -3,103 +3,100 @@
33
# Licensed under the MIT License. See License in the project root for license information.
44
# ------------------------------------------------------------------------------
55
function Add-EntraServicePrincipalDelegatedPermissionClassification {
6-
[CmdletBinding(DefaultParameterSetName = 'InvokeByDynamicParameters')]
7-
param (
6+
[CmdletBinding(DefaultParameterSetName = 'ByServicePrincipalAndPermissionInfo')]
7+
param (
8+
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Unique ID of the service principal object (Service Principal Object ID).")]
9+
[Alias('ObjectId')]
10+
[ValidateNotNullOrEmpty()]
11+
[guid] $ServicePrincipalId,
812

9-
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
10-
[System.String] $ServicePrincipalId,
13+
[Parameter(ParameterSetName = "ByServicePrincipalAndPermissionInfo", Mandatory = $true, HelpMessage = "Permission classification. e.g. Low, Medium, High")]
14+
[ValidateNotNullOrEmpty()]
15+
[System.Nullable`1[Microsoft.Open.MSGraph.Model.DelegatedPermissionClassification+ClassificationEnum]] $Classification,
1116

12-
[Parameter(ParameterSetName = "InvokeByDynamicParameters", Mandatory = $true)]
13-
[System.Nullable`1[Microsoft.Open.MSGraph.Model.DelegatedPermissionClassification+ClassificationEnum]] $Classification,
17+
[Parameter(ParameterSetName = "ByServicePrincipalAndPermissionInfo", Mandatory = $true, HelpMessage = "Unique ID of the permission. e.g. 00000000-0000-0000-0000-000000000000")]
18+
[ValidateNotNullOrEmpty()]
19+
[guid] $PermissionId,
1420

15-
[Parameter(ParameterSetName = "InvokeByDynamicParameters", Mandatory = $true)]
16-
[System.String] $PermissionId,
17-
18-
[Parameter(ParameterSetName = "InvokeByDynamicParameters", Mandatory = $true)]
19-
[System.String] $PermissionName
21+
[Parameter(ParameterSetName = "ByServicePrincipalAndPermissionInfo", Mandatory = $true, HelpMessage = "Name of the permission. e.g. HR.Read.All")]
22+
[ValidateNotNullOrEmpty()]
23+
[System.String] $PermissionName
2024
)
2125

26+
begin {
27+
# Ensure connection to Microsoft Entra
28+
if (-not (Get-EntraContext)) {
29+
$errorMessage = "Not connected to Microsoft Graph. Use 'Connect-Entra -Scopes Policy.ReadWrite.PermissionGrant' to authenticate."
30+
Write-Error -Message $errorMessage -ErrorAction Stop
31+
return
32+
}
33+
}
34+
2235
PROCESS {
23-
$params = @{}
24-
$customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand
36+
$params = @{}
37+
$customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand
2538

26-
if ($null -ne $PSBoundParameters["ServicePrincipalId"])
27-
{
28-
$params["ServicePrincipalId"] = $PSBoundParameters["ServicePrincipalId"]
29-
}
30-
if($PSBoundParameters.ContainsKey("Debug"))
31-
{
32-
$params["Debug"] = $PSBoundParameters["Debug"]
33-
}
34-
if ($null -ne $PSBoundParameters["PipelineVariable"])
35-
{
36-
$params["PipelineVariable"] = $PSBoundParameters["PipelineVariable"]
37-
}
38-
if ($null -ne $PSBoundParameters["InformationVariable"])
39-
{
40-
$params["InformationVariable"] = $PSBoundParameters["InformationVariable"]
41-
}
42-
if ($null -ne $PSBoundParameters["Classification"])
43-
{
44-
$params["Classification"] = $PSBoundParameters["Classification"]
45-
}
46-
if ($null -ne $PSBoundParameters["OutBuffer"])
47-
{
48-
$params["OutBuffer"] = $PSBoundParameters["OutBuffer"]
49-
}
50-
if ($null -ne $PSBoundParameters["WarningVariable"])
51-
{
52-
$params["WarningVariable"] = $PSBoundParameters["WarningVariable"]
53-
}
54-
if($PSBoundParameters.ContainsKey("Verbose"))
55-
{
56-
$params["Verbose"] = $PSBoundParameters["Verbose"]
57-
}
58-
if ($null -ne $PSBoundParameters["PermissionId"])
59-
{
60-
$params["PermissionId"] = $PSBoundParameters["PermissionId"]
61-
}
62-
if ($null -ne $PSBoundParameters["PermissionName"])
63-
{
64-
$params["PermissionName"] = $PSBoundParameters["PermissionName"]
65-
}
66-
if ($null -ne $PSBoundParameters["ErrorVariable"])
67-
{
68-
$params["ErrorVariable"] = $PSBoundParameters["ErrorVariable"]
69-
}
70-
if ($null -ne $PSBoundParameters["ErrorAction"])
71-
{
72-
$params["ErrorAction"] = $PSBoundParameters["ErrorAction"]
73-
}
74-
if ($null -ne $PSBoundParameters["InformationAction"])
75-
{
76-
$params["InformationAction"] = $PSBoundParameters["InformationAction"]
77-
}
78-
if ($null -ne $PSBoundParameters["WarningAction"])
79-
{
80-
$params["WarningAction"] = $PSBoundParameters["WarningAction"]
81-
}
82-
if ($null -ne $PSBoundParameters["ProgressAction"])
83-
{
84-
$params["ProgressAction"] = $PSBoundParameters["ProgressAction"]
85-
}
86-
if ($null -ne $PSBoundParameters["OutVariable"])
87-
{
88-
$params["OutVariable"] = $PSBoundParameters["OutVariable"]
89-
}
39+
if ($null -ne $PSBoundParameters["ServicePrincipalId"]) {
40+
$params["ServicePrincipalId"] = $PSBoundParameters["ServicePrincipalId"]
41+
}
42+
if ($PSBoundParameters.ContainsKey("Debug")) {
43+
$params["Debug"] = $PSBoundParameters["Debug"]
44+
}
45+
if ($null -ne $PSBoundParameters["PipelineVariable"]) {
46+
$params["PipelineVariable"] = $PSBoundParameters["PipelineVariable"]
47+
}
48+
if ($null -ne $PSBoundParameters["InformationVariable"]) {
49+
$params["InformationVariable"] = $PSBoundParameters["InformationVariable"]
50+
}
51+
if ($null -ne $PSBoundParameters["Classification"]) {
52+
$params["Classification"] = $PSBoundParameters["Classification"]
53+
}
54+
if ($null -ne $PSBoundParameters["OutBuffer"]) {
55+
$params["OutBuffer"] = $PSBoundParameters["OutBuffer"]
56+
}
57+
if ($null -ne $PSBoundParameters["WarningVariable"]) {
58+
$params["WarningVariable"] = $PSBoundParameters["WarningVariable"]
59+
}
60+
if ($PSBoundParameters.ContainsKey("Verbose")) {
61+
$params["Verbose"] = $PSBoundParameters["Verbose"]
62+
}
63+
if ($null -ne $PSBoundParameters["PermissionId"]) {
64+
$params["PermissionId"] = $PSBoundParameters["PermissionId"]
65+
}
66+
if ($null -ne $PSBoundParameters["PermissionName"]) {
67+
$params["PermissionName"] = $PSBoundParameters["PermissionName"]
68+
}
69+
if ($null -ne $PSBoundParameters["ErrorVariable"]) {
70+
$params["ErrorVariable"] = $PSBoundParameters["ErrorVariable"]
71+
}
72+
if ($null -ne $PSBoundParameters["ErrorAction"]) {
73+
$params["ErrorAction"] = $PSBoundParameters["ErrorAction"]
74+
}
75+
if ($null -ne $PSBoundParameters["InformationAction"]) {
76+
$params["InformationAction"] = $PSBoundParameters["InformationAction"]
77+
}
78+
if ($null -ne $PSBoundParameters["WarningAction"]) {
79+
$params["WarningAction"] = $PSBoundParameters["WarningAction"]
80+
}
81+
if ($null -ne $PSBoundParameters["ProgressAction"]) {
82+
$params["ProgressAction"] = $PSBoundParameters["ProgressAction"]
83+
}
84+
if ($null -ne $PSBoundParameters["OutVariable"]) {
85+
$params["OutVariable"] = $PSBoundParameters["OutVariable"]
86+
}
9087

91-
Write-Debug("============================ TRANSFORMATIONS ============================")
92-
$params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug
93-
Write-Debug("=========================================================================`n")
88+
Write-Debug("============================ TRANSFORMATIONS ============================")
89+
$params.Keys | ForEach-Object { "$_ : $($params[$_])" } | Write-Debug
90+
Write-Debug("=========================================================================`n")
9491

95-
$response = New-MgServicePrincipalDelegatedPermissionClassification @params -Headers $customHeaders
96-
$response | ForEach-Object {
97-
if($null -ne $_) {
98-
Add-Member -InputObject $_ -MemberType AliasProperty -Name ObjectId -Value Id
92+
$response = New-MgServicePrincipalDelegatedPermissionClassification @params -Headers $customHeaders
93+
$response | ForEach-Object {
94+
if ($null -ne $_) {
95+
Add-Member -InputObject $_ -MemberType AliasProperty -Name ObjectId -Value Id
9996

97+
}
10098
}
101-
}
102-
$response
99+
$response
103100
}
104101
}
105102

module/Entra/Microsoft.Entra/Applications/Add-EntraServicePrincipalOwner.ps1

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,38 @@
33
# Licensed under the MIT License. See License in the project root for license information.
44
# ------------------------------------------------------------------------------
55
function Add-EntraServicePrincipalOwner {
6-
[CmdletBinding(DefaultParameterSetName = '')]
6+
[CmdletBinding(DefaultParameterSetName = 'ByServicePrincipalIdAndOwnerId')]
77
param (
88
[Alias('ObjectId')]
99
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Unique ID of the service principal.")]
10+
[ValidateNotNullOrEmpty()]
1011
[System.String] $ServicePrincipalId,
1112

1213
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Unique ID of the owner, which can be a user, the service principal itself, or another service principal.")]
1314
[Alias('RefObjectId')]
15+
[ValidateNotNullOrEmpty()]
1416
[System.String] $OwnerId
1517
)
1618

19+
begin {
20+
# Ensure connection to Microsoft Entra
21+
if (-not (Get-EntraContext)) {
22+
$errorMessage = "Not connected to Microsoft Graph. Use 'Connect-Entra -Scopes Application.ReadWrite.All' to authenticate."
23+
Write-Error -Message $errorMessage -ErrorAction Stop
24+
return
25+
}
26+
}
27+
1728
PROCESS {
1829
$params = @{}
1930
$customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand
2031

32+
$rootUri = (Get-EntraEnvironment -Name (Get-EntraContext).Environment).GraphEndpoint
33+
34+
if (-not $rootUri) {
35+
$rootUri = "https://graph.microsoft.com"
36+
Write-Verbose "Using default Graph endpoint: $rootUri"
37+
}
2138
if ($null -ne $PSBoundParameters["OutVariable"]) {
2239
$params["OutVariable"] = $PSBoundParameters["OutVariable"]
2340
}
@@ -59,7 +76,7 @@ function Add-EntraServicePrincipalOwner {
5976
}
6077
if ($null -ne $PSBoundParameters["OwnerId"]) {
6178
$TmpValue = $PSBoundParameters["OwnerId"]
62-
$Value = @{ "@odata.id" = "https://graph.microsoft.com/v1.0/directoryObjects/$TmpValue" }
79+
$Value = @{ "@odata.id" = "$rootUri/v1.0/directoryObjects/$TmpValue" }
6380
$params["BodyParameter"] = $Value
6481
}
6582

0 commit comments

Comments
 (0)