Skip to content

Commit 31b7215

Browse files
authored
AppendSelected parameter (#1518)
1 parent 135bf7e commit 31b7215

28 files changed

+1160
-81
lines changed

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
function Get-EntraServicePrincipalOwner {
66
[CmdletBinding(DefaultParameterSetName = 'GetQuery')]
77
param (
8-
[Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "The number of items to return in the response.")]
8+
[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "The number of items to return in the response.")]
99
[Alias("Limit")]
1010
[System.Nullable`1[System.Int32]] $Top,
1111

@@ -17,9 +17,13 @@ function Get-EntraServicePrincipalOwner {
1717
[ValidateNotNullOrEmpty()]
1818
[System.String] $ServicePrincipalId,
1919

20-
[Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = "Properties to include in the results.")]
20+
[Parameter(ParameterSetName = "GetQuery",Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = "Properties to include in the results.")]
21+
[Parameter(ParameterSetName = "Append",Mandatory = $true, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = "Properties to include in the results.")]
2122
[Alias("Select")]
22-
[System.String[]] $Property
23+
[System.String[]] $Property,
24+
25+
[Parameter(ParameterSetName = "Append", Mandatory = $true, HelpMessage = "Specifies whether to append the selected properties.")]
26+
[switch] $AppendSelected
2327
)
2428

2529
begin {
@@ -31,9 +35,11 @@ function Get-EntraServicePrincipalOwner {
3135
}
3236
}
3337

34-
PROCESS {
38+
PROCESS {
3539
$params = @{}
36-
$customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand
40+
$customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand
41+
$defaultProperties = "id,displayName,createdDateTime,deletedDateTime,accountEnabled"
42+
3743
if ($PSBoundParameters.ContainsKey("Verbose")) {
3844
$params["Verbose"] = $PSBoundParameters["Verbose"]
3945
}
@@ -78,8 +84,11 @@ function Get-EntraServicePrincipalOwner {
7884
if ($null -ne $PSBoundParameters["WarningAction"]) {
7985
$params["WarningAction"] = $PSBoundParameters["WarningAction"]
8086
}
81-
if ($null -ne $PSBoundParameters["Property"]) {
82-
$params["Property"] = $PSBoundParameters["Property"]
87+
if ($null -ne $Property -and $Property.Count -gt 0) {
88+
$params["Property"] = $Property -join ','
89+
}
90+
if ($PSBoundParameters.ContainsKey("AppendSelected")) {
91+
$params["Property"] = $defaultProperties + "," + ($Property -join ',')
8392
}
8493

8594
Write-Debug("============================ TRANSFORMATIONS ============================")

module/Entra/Microsoft.Entra/Groups/Get-EntraGroup.ps1

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,38 @@
44
# ------------------------------------------------------------------------------
55
function Get-EntraGroup {
66
[CmdletBinding(DefaultParameterSetName = 'GetQuery')]
7-
param (
7+
param (
88
[Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "The maximum number of items to return.")]
9+
[Parameter(ParameterSetName = "Append", ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = "The maximum number of items to return.")]
910
[Alias("Limit")]
1011
[System.Nullable`1[System.Int32]] $Top,
1112

1213
[Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Filter the results based on the specified criteria.")]
14+
[Parameter(ParameterSetName = "Append", ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = "Filter the results based on the specified criteria.")]
1315
[System.String] $Filter,
1416

1517
[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Specifies whether to return all objects.")]
1618
[switch] $All,
1719

1820
[Parameter(ParameterSetName = "GetVague", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Search for a group by its name, email, or mail nickname.")]
21+
[Parameter(ParameterSetName = "Append", ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = "Search for a group by its name, email, or mail nickname.")]
1922
[System.String] $SearchString,
2023

21-
[Alias('ObjectId')]
24+
[Alias('ObjectId')]
2225
[Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "The ID of the group to retrieve. Should be a valid GUID value.")]
26+
[Parameter(ParameterSetName = "Append", Mandatory = $false, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "The ID of the group to retrieve. Should be a valid GUID value.")]
2327
[ValidateNotNullOrEmpty()]
2428
[Guid] $GroupId,
2529

26-
[Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = "Properties to include in the results.")]
30+
[Parameter(ParameterSetName = "GetQuery", Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = "Properties to include in the results.")]
31+
[Parameter(ParameterSetName = "GetVague", Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = "Properties to include in the results.")]
32+
[Parameter(ParameterSetName = "GetById", Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = "Properties to include in the results.")]
33+
[Parameter(ParameterSetName = "Append", Mandatory = $true, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = "Properties to include in the results.")]
2734
[Alias("Select")]
28-
[System.String[]] $Property
35+
[System.String[]] $Property,
36+
37+
[Parameter(ParameterSetName = "Append", Mandatory = $true, HelpMessage = "Specifies whether to append the selected properties.")]
38+
[switch] $AppendSelected
2939
)
3040

3141
begin {
@@ -41,6 +51,7 @@ function Get-EntraGroup {
4151
$params = @{}
4252
$customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand
4353
$keysChanged = @{SearchString = "Filter"; ObjectId = "Id" }
54+
$defaultProperties = "id,displayName,createdDateTime,deletedDateTime,groupTypes,mailEnabled,mailNickname,securityEnabled,visibility,description"
4455
if ($null -ne $PSBoundParameters["OutVariable"]) {
4556
$params["OutVariable"] = $PSBoundParameters["OutVariable"]
4657
}
@@ -101,8 +112,11 @@ function Get-EntraGroup {
101112
if ($null -ne $PSBoundParameters["ProgressAction"]) {
102113
$params["ProgressAction"] = $PSBoundParameters["ProgressAction"]
103114
}
104-
if ($null -ne $PSBoundParameters["Property"]) {
105-
$params["Property"] = $PSBoundParameters["Property"]
115+
if ($null -ne $Property -and $Property.Count -gt 0) {
116+
$params["Property"] = $Property -join ','
117+
}
118+
if ($PSBoundParameters.ContainsKey("AppendSelected")) {
119+
$params["Property"] = $defaultProperties + "," + ($Property -join ',')
106120
}
107121

108122
Write-Debug("============================ TRANSFORMATIONS ============================")

module/Entra/Microsoft.Entra/Users/Get-EntraUserGroup.ps1

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ function Get-EntraUserGroup {
66
[CmdletBinding(DefaultParameterSetName = 'GetQuery')]
77
param (
88
[Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Filter to apply to the query.")]
9+
[Parameter(ParameterSetName = "Append", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Filter to apply to the query.")]
910
[System.String] $Filter,
1011

1112
[Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Retrieve all user's group memberships.")]
13+
[Parameter(ParameterSetName = "Append", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Retrieve all user's group memberships.")]
1214
[switch] $All,
1315

1416
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "User object ID or UPN to retrieve.")]
@@ -24,16 +26,21 @@ function Get-EntraUserGroup {
2426
[System.String] $UserId,
2527

2628
[Alias('DirectoryObjectId')]
27-
[Parameter(ParameterSetName = "GetById", Mandatory = $false, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Group object ID to retrieve.")]
29+
[Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Group object ID to retrieve.")]
2830
[System.String] $GroupId,
2931

3032
[Alias('Limit')]
3133
[Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Maximum number of results to return.")]
34+
[Parameter(ParameterSetName = "Append", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Maximum number of results to return.")]
3235
[System.Nullable`1[System.Int32]] $Top,
3336

3437
[Alias('Select')]
35-
[Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = "Properties to include in the results.")]
36-
[System.String[]] $Property
38+
[Parameter(ParameterSetName = "Append",Mandatory = $true, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = "Properties to include in the results.")]
39+
[Parameter(ParameterSetName = "GetQuery",Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = "Properties to include in the results.")]
40+
[System.String[]] $Property,
41+
42+
[Parameter(ParameterSetName = "Append", Mandatory = $true, HelpMessage = "Specifies whether to append the selected properties.")]
43+
[switch] $AppendSelected
3744
)
3845

3946
begin {
@@ -49,6 +56,7 @@ function Get-EntraUserGroup {
4956
$params = @{}
5057
$customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand
5158
$keysChanged = @{ SearchString = "Filter" }
59+
$defaultProperties = "id,displayName,createdDateTime,deletedDateTime,groupTypes,mailEnabled,mailNickname,securityEnabled,visibility,description"
5260

5361
if ($null -ne $PSBoundParameters["ErrorAction"]) {
5462
$params["ErrorAction"] = $PSBoundParameters["ErrorAction"]
@@ -105,8 +113,11 @@ function Get-EntraUserGroup {
105113
if ($null -ne $PSBoundParameters["InformationVariable"]) {
106114
$params["InformationVariable"] = $PSBoundParameters["InformationVariable"]
107115
}
108-
if ($null -ne $PSBoundParameters["Property"]) {
109-
$params["Property"] = $PSBoundParameters["Property"]
116+
if ($null -ne $Property -and $Property.Count -gt 0) {
117+
$params["Property"] = $Property -join ','
118+
}
119+
if ($PSBoundParameters.ContainsKey("AppendSelected")) {
120+
$params["Property"] = $defaultProperties + "," + ($Property -join ',')
110121
}
111122

112123
# Debug logging for transformations

module/EntraBeta/Microsoft.Entra.Beta/Applications/Get-EntraBetaApplicationOwner.ps1

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@ function Get-EntraBetaApplicationOwner {
1313
[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Get all owners of the application.")]
1414
[switch] $All,
1515

16-
[Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "The number of items to return.")]
16+
[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "The number of items to return.")]
1717
[Alias("Limit")]
1818
[System.Nullable`1[System.Int32]] $Top,
1919

20-
[Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = "Properties to include in the results.")]
20+
[Parameter(ParameterSetName = "GetQuery",Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = "Properties to include in the results.")]
21+
[Parameter(ParameterSetName = "Append",Mandatory = $true, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = "Properties to include in the results.")]
2122
[Alias("Select")]
22-
[System.String[]] $Property
23+
[System.String[]] $Property,
24+
25+
[Parameter(ParameterSetName = "Append", Mandatory = $true, HelpMessage = "Specifies whether to append the selected properties.")]
26+
[switch] $AppendSelected
2327
)
2428

2529
begin {
@@ -34,6 +38,7 @@ function Get-EntraBetaApplicationOwner {
3438
PROCESS {
3539
$params = @{}
3640
$customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand
41+
$defaultProperties = "id,displayName,createdDateTime,deletedDateTime,accountEnabled"
3742

3843
if ($PSBoundParameters.ContainsKey("Verbose")) {
3944
$params["Verbose"] = $PSBoundParameters["Verbose"]
@@ -79,8 +84,11 @@ function Get-EntraBetaApplicationOwner {
7984
if ($null -ne $PSBoundParameters["WarningAction"]) {
8085
$params["WarningAction"] = $PSBoundParameters["WarningAction"]
8186
}
82-
if ($null -ne $PSBoundParameters["Property"]) {
83-
$params["Property"] = $PSBoundParameters["Property"]
87+
if ($null -ne $Property -and $Property.Count -gt 0) {
88+
$params["Property"] = $Property -join ','
89+
}
90+
if ($PSBoundParameters.ContainsKey("AppendSelected")) {
91+
$params["Property"] = $defaultProperties + "," + ($Property -join ',')
8492
}
8593

8694
Write-Debug("============================ TRANSFORMATIONS ============================")

module/EntraBeta/Microsoft.Entra.Beta/Applications/Get-EntraBetaServicePrincipalOwner.ps1

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
function Get-EntraBetaServicePrincipalOwner {
66
[CmdletBinding(DefaultParameterSetName = 'GetQuery')]
77
param (
8-
[Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "The number of items to return in the response.")]
8+
[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "The number of items to return in the response.")]
99
[Alias("Limit")]
1010
[System.Nullable`1[System.Int32]] $Top,
1111

@@ -17,9 +17,13 @@ function Get-EntraBetaServicePrincipalOwner {
1717
[ValidateNotNullOrEmpty()]
1818
[System.String] $ServicePrincipalId,
1919

20-
[Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = "Properties to include in the results.")]
20+
[Parameter(ParameterSetName = "GetQuery",Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = "Properties to include in the results.")]
21+
[Parameter(ParameterSetName = "Append",Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true, HelpMessage = "Properties to include in the results.")]
2122
[Alias("Select")]
22-
[System.String[]] $Property
23+
[System.String[]] $Property,
24+
25+
[Parameter(ParameterSetName = "Append", Mandatory = $true, HelpMessage = "Specifies whether to append the selected properties.")]
26+
[switch] $AppendSelected
2327
)
2428

2529
begin {
@@ -34,6 +38,7 @@ function Get-EntraBetaServicePrincipalOwner {
3438
PROCESS {
3539
$params = @{}
3640
$customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand
41+
$defaultProperties = "id,displayName,createdDateTime,deletedDateTime,accountEnabled"
3742

3843
if ($null -ne $PSBoundParameters["ServicePrincipalId"]) {
3944
$params["ServicePrincipalId"] = $PSBoundParameters["ServicePrincipalId"]
@@ -49,9 +54,13 @@ function Get-EntraBetaServicePrincipalOwner {
4954
if ($PSBoundParameters.ContainsKey("Top")) {
5055
$params["Top"] = $PSBoundParameters["Top"]
5156
}
52-
if ($null -ne $PSBoundParameters["Property"]) {
53-
$params["Property"] = $PSBoundParameters["Property"]
57+
if ($null -ne $Property -and $Property.Count -gt 0) {
58+
$params["Property"] = $Property -join ','
59+
}
60+
if ($PSBoundParameters.ContainsKey("AppendSelected")) {
61+
$params["Property"] = $defaultProperties + "," + ($Property -join ',')
5462
}
63+
5564
# Add common parameters if they exist
5665
$commonParams = @("WarningVariable", "InformationVariable", "InformationAction", "OutVariable", "OutBuffer", "ErrorVariable", "PipelineVariable", "ErrorAction", "WarningAction")
5766
foreach ($param in $commonParams) {

0 commit comments

Comments
 (0)