Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding limit and select aliases - Beta commands #1221

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# ------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
# ------------------------------------------------------------------------------

function Get-EntraBetaApplicationPasswordCredential {
[CmdletBinding(DefaultParameterSetName = '')]
param (
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[Alias("ObjectId")]
[System.String] $ApplicationId,
[Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)]
[System.String[]] $Property
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[Alias("ObjectId")]
[System.String] $ApplicationId,

[Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)]
[Alias("Select")]
[System.String[]] $Property
)

PROCESS {
Expand Down
153 changes: 80 additions & 73 deletions module/EntraBeta/customizations/Get-EntraBetaApplication.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,136 +9,143 @@
CustomScript = @'
[CmdletBinding(DefaultParameterSetName = 'GetQuery')]
param (
[Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[System.String] $Filter,
[Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[System.Nullable`1[System.Int32]] $Top,
[Alias("ObjectId")]
[Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[System.String] $ApplicationId,
[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[switch] $All,
[Parameter(ParameterSetName = "GetVague", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[System.String] $SearchString,
[Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)]
[System.String[]] $Property
[Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[System.String] $Filter,

[Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[Alias("Limit")]
[System.Nullable`1[System.Int32]] $Top,

[Alias("ObjectId")]
[Parameter(ParameterSetName = "GetById", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[System.String] $ApplicationId,

[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[switch] $All,

[Parameter(ParameterSetName = "GetVague", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[System.String] $SearchString,

[Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)]
[Alias("Select")]
[System.String[]] $Property
)

PROCESS {
$params = @{}
$customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand
$keysChanged = @{SearchString = "Filter"; ObjectId = "Id"}
if($null -ne $PSBoundParameters["SearchString"])
{

if ($null -ne $PSBoundParameters["SearchString"]) {
$TmpValue = $PSBoundParameters["SearchString"]
$Value = "displayName eq '$TmpValue' or startswith(displayName,'$TmpValue')"
$params["Filter"] = $Value
}
if($null -ne $PSBoundParameters["ApplicationId"])
{

if ($null -ne $PSBoundParameters["ApplicationId"]) {
$params["ApplicationId"] = $PSBoundParameters["ApplicationId"]
}
if($null -ne $PSBoundParameters["Filter"])
{

if ($null -ne $PSBoundParameters["Filter"]) {
$TmpValue = $PSBoundParameters["Filter"]
foreach($i in $keysChanged.GetEnumerator()){
foreach ($i in $keysChanged.GetEnumerator()) {
$TmpValue = $TmpValue.Replace($i.Key, $i.Value)
}
$Value = $TmpValue
$params["Filter"] = $Value
}
if($PSBoundParameters.ContainsKey("Verbose"))
{

if ($PSBoundParameters.ContainsKey("Verbose")) {
$params["Verbose"] = $PSBoundParameters["Verbose"]
}
if($null -ne $PSBoundParameters["All"])
{
if($PSBoundParameters["All"])
{

if ($null -ne $PSBoundParameters["All"]) {
if ($PSBoundParameters["All"]) {
$params["All"] = $PSBoundParameters["All"]
}
}
if($PSBoundParameters.ContainsKey("Debug"))
{

if ($PSBoundParameters.ContainsKey("Debug")) {
$params["Debug"] = $PSBoundParameters["Debug"]
}
if($PSBoundParameters.ContainsKey("Top"))
{

if ($PSBoundParameters.ContainsKey("Top")) {
$params["Top"] = $PSBoundParameters["Top"]
}
if($null -ne $PSBoundParameters["WarningVariable"])
{

if ($null -ne $PSBoundParameters["WarningVariable"]) {
$params["WarningVariable"] = $PSBoundParameters["WarningVariable"]
}
if($null -ne $PSBoundParameters["InformationVariable"])
{

if ($null -ne $PSBoundParameters["InformationVariable"]) {
$params["InformationVariable"] = $PSBoundParameters["InformationVariable"]
}
if($null -ne $PSBoundParameters["InformationAction"])
{
if ($null -ne $PSBoundParameters["InformationAction"]) {
$params["InformationAction"] = $PSBoundParameters["InformationAction"]
}
if($null -ne $PSBoundParameters["OutVariable"])
{

if ($null -ne $PSBoundParameters["OutVariable"]) {
$params["OutVariable"] = $PSBoundParameters["OutVariable"]
}
if($null -ne $PSBoundParameters["OutBuffer"])
{

if ($null -ne $PSBoundParameters["OutBuffer"]) {
$params["OutBuffer"] = $PSBoundParameters["OutBuffer"]
}
if($null -ne $PSBoundParameters["ErrorVariable"])
{

if ($null -ne $PSBoundParameters["ErrorVariable"]) {
$params["ErrorVariable"] = $PSBoundParameters["ErrorVariable"]
}
if($null -ne $PSBoundParameters["PipelineVariable"])
{

if ($null -ne $PSBoundParameters["PipelineVariable"]) {
$params["PipelineVariable"] = $PSBoundParameters["PipelineVariable"]
}
if($null -ne $PSBoundParameters["ErrorAction"])
{

if ($null -ne $PSBoundParameters["ErrorAction"]) {
$params["ErrorAction"] = $PSBoundParameters["ErrorAction"]
}
if($null -ne $PSBoundParameters["WarningAction"])
{

if ($null -ne $PSBoundParameters["WarningAction"]) {
$params["WarningAction"] = $PSBoundParameters["WarningAction"]
}
if($null -ne $PSBoundParameters["Property"])
{

if ($null -ne $PSBoundParameters["Property"]) {
$params["Property"] = $PSBoundParameters["Property"]
}

Write-Debug("============================ TRANSFORMATIONS ============================")
$params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug
$params.Keys | ForEach-Object { "$_ : $($params[$_])" } | Write-Debug
Write-Debug("=========================================================================")

$response = Get-MgBetaApplication @params -Headers $customHeaders
$response | ForEach-Object {
if($null -ne $_) {
Add-Member -InputObject $_ -MemberType AliasProperty -Name ObjectId -Value Id
Add-Member -InputObject $_ -MemberType AliasProperty -Name DeletionTimestamp -Value DeletedDateTime
Add-Member -InputObject $_ -MemberType AliasProperty -Name InformationalUrls -Value Info
if ($null -ne $_) {
Add-Member -InputObject $_ -MemberType AliasProperty -Name ObjectId -Value Id
Add-Member -InputObject $_ -MemberType AliasProperty -Name DeletionTimestamp -Value DeletedDateTime
Add-Member -InputObject $_ -MemberType AliasProperty -Name InformationalUrls -Value Info

$myAppRoles = New-Object System.Collections.Generic.List[Microsoft.Open.AzureAD.Model.AppRole]
foreach ($appRole in $_.AppRoles) {
$hash = New-Object Microsoft.Open.AzureAD.Model.AppRole
foreach ($propertyName in $hash.psobject.Properties.Name) {
$hash.$propertyName = $appRole.$propertyName
$myAppRoles = New-Object System.Collections.Generic.List[Microsoft.Open.AzureAD.Model.AppRole]
foreach ($appRole in $_.AppRoles) {
$hash = New-Object Microsoft.Open.AzureAD.Model.AppRole
foreach ($propertyName in $hash.psobject.Properties.Name) {
$hash.$propertyName = $appRole.$propertyName
}
$myAppRoles.Add($hash)
}
$myAppRoles.Add($hash)
}
Add-Member -InputObject $_ -MemberType NoteProperty -Name AppRoles -Value ($myAppRoles) -Force
$propsToConvert = @(
'Logo','GroupMembershipClaims','IdentifierUris','Info',
'IsDeviceOnlyAuthSupported','KeyCredentials','Oauth2RequirePostResponse','OptionalClaims',
'ParentalControlSettings','PasswordCredentials','Api','PublicClient',
'PublisherDomain','Web','RequiredResourceAccess','SignInAudience')
try {
Add-Member -InputObject $_ -MemberType NoteProperty -Name AppRoles -Value ($myAppRoles) -Force
$propsToConvert = @(
'Logo','GroupMembershipClaims','IdentifierUris','Info',
'IsDeviceOnlyAuthSupported','KeyCredentials','Oauth2RequirePostResponse','OptionalClaims',
'ParentalControlSettings','PasswordCredentials','Api','PublicClient',
'PublisherDomain','Web','RequiredResourceAccess','SignInAudience'
)
try {
foreach ($prop in $propsToConvert) {
$value = $_.$prop | ConvertTo-Json | ConvertFrom-Json
$_ | Add-Member -MemberType NoteProperty -Name $prop -Value ($value) -Force
$value = $_.$prop | ConvertTo-Json | ConvertFrom-Json
$_ | Add-Member -MemberType NoteProperty -Name $prop -Value ($value) -Force
}
}
catch {}
}
catch {}
}
foreach ($credType in @('KeyCredentials', 'PasswordCredentials')) {
if ($null -ne $_.PSObject.Properties[$credType]) {
Expand Down
76 changes: 33 additions & 43 deletions module/EntraBeta/customizations/Get-EntraBetaApplicationOwner.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,86 +9,76 @@
CustomScript = @'
[CmdletBinding(DefaultParameterSetName = 'GetQuery')]
param (
[Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[System.Nullable`1[System.Int32]] $Top,
[Alias('ObjectId')]
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[System.String] $ApplicationId,
[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[switch] $All,
[Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)]
[System.String[]] $Property
[Parameter(ParameterSetName = "GetQuery", ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[Alias("Limit")]
[System.Nullable`1[System.Int32]] $Top,

[Alias('ObjectId')]
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[System.String] $ApplicationId,

[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[switch] $All,

[Parameter(Mandatory = $false, ValueFromPipeline = $false, ValueFromPipelineByPropertyName = $true)]
[Alias("Select")]
[System.String[]] $Property
)

PROCESS {
$params = @{}
$customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand

if($PSBoundParameters.ContainsKey("Verbose"))
{
if ($PSBoundParameters.ContainsKey("Verbose")) {
$params["Verbose"] = $PSBoundParameters["Verbose"]
}
if($null -ne $PSBoundParameters["ApplicationId"])
{
if ($null -ne $PSBoundParameters["ApplicationId"]) {
$params["ApplicationId"] = $PSBoundParameters["ApplicationId"]
}
if($null -ne $PSBoundParameters["All"])
{
if($PSBoundParameters["All"])
{
if ($null -ne $PSBoundParameters["All"]) {
if ($PSBoundParameters["All"]) {
$params["All"] = $PSBoundParameters["All"]
}
}
if($PSBoundParameters.ContainsKey("Debug"))
{
if ($PSBoundParameters.ContainsKey("Debug")) {
$params["Debug"] = $PSBoundParameters["Debug"]
}
if($PSBoundParameters.ContainsKey("Top"))
{
if ($PSBoundParameters.ContainsKey("Top")) {
$params["Top"] = $PSBoundParameters["Top"]
}
if($null -ne $PSBoundParameters["WarningVariable"])
{
if ($null -ne $PSBoundParameters["WarningVariable"]) {
$params["WarningVariable"] = $PSBoundParameters["WarningVariable"]
}
if($null -ne $PSBoundParameters["InformationVariable"])
{
if ($null -ne $PSBoundParameters["InformationVariable"]) {
$params["InformationVariable"] = $PSBoundParameters["InformationVariable"]
}
if($null -ne $PSBoundParameters["InformationAction"])
{
if ($null -ne $PSBoundParameters["InformationAction"]) {
$params["InformationAction"] = $PSBoundParameters["InformationAction"]
}
if($null -ne $PSBoundParameters["OutVariable"])
{
if ($null -ne $PSBoundParameters["OutVariable"]) {
$params["OutVariable"] = $PSBoundParameters["OutVariable"]
}
if($null -ne $PSBoundParameters["OutBuffer"])
{
if ($null -ne $PSBoundParameters["OutBuffer"]) {
$params["OutBuffer"] = $PSBoundParameters["OutBuffer"]
}
if($null -ne $PSBoundParameters["ErrorVariable"])
{
if ($null -ne $PSBoundParameters["ErrorVariable"]) {
$params["ErrorVariable"] = $PSBoundParameters["ErrorVariable"]
}
if($null -ne $PSBoundParameters["PipelineVariable"])
{
if ($null -ne $PSBoundParameters["PipelineVariable"]) {
$params["PipelineVariable"] = $PSBoundParameters["PipelineVariable"]
}
if($null -ne $PSBoundParameters["ErrorAction"])
{
if ($null -ne $PSBoundParameters["ErrorAction"]) {
$params["ErrorAction"] = $PSBoundParameters["ErrorAction"]
}
if($null -ne $PSBoundParameters["WarningAction"])
{
if ($null -ne $PSBoundParameters["WarningAction"]) {
$params["WarningAction"] = $PSBoundParameters["WarningAction"]
}
if($null -ne $PSBoundParameters["Property"])
{
if ($null -ne $PSBoundParameters["Property"]) {
$params["Property"] = $PSBoundParameters["Property"]
}

Write-Debug("============================ TRANSFORMATIONS ============================")
$params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug
$params.Keys | ForEach-Object { "$_ : $($params[$_])" } | Write-Debug
Write-Debug("=========================================================================`n")

$response = Get-MgBetaApplicationOwner @params -Headers $customHeaders
Expand All @@ -107,6 +97,6 @@
}
}
$response
}
}
'@
}
Loading