Are there any plans to make make the commands in this module more idiomatic?
Primarily, it's necessary to create an object to execute any of the following commands:
New-AzureADDirectorySetting
New-AzureADObjectSetting
New-AzureADTrustedCertificateAuthority
New-AzureADUser
Remove-AzureADTrustedCertificateAuthority
Select-AzureADGroupIdsContactIsMemberOf
Select-AzureADGroupIdsGroupIsMemberOf
Select-AzureADGroupIdsServicePrincipalIsMemberOf
Select-AzureADGroupIdsUserIsMemberOf
Set-AzureADDirectorySetting
Set-AzureADObjectSetting
Set-AzureADTrustedCertificateAuthority
Set-AzureADUserLicense
Sometimes it's possible to avoid creating the objects explicitly, but the result is very strange. For example, instead of creating a Microsoft.Open.AzureAD.Model.GroupIdsForMembershipCheck, implicitly create it from a hashtable:
Select-AzureADGroupIdsUserIsMemberOf -ObjectId (
Get-AzureADUser -SearchString someusername |% ObjectID
) -GroupIdsForMembershipCheck @{
GroupIds = Get-AzureADGroup | select -first 20 |% ObjectId
}
A more idiomatic usage pattern would be:
Select-AzureADGroupIdsUserIsMemberOf -UserPrincipalName someuser@example.com -Groups Group1,Group2,Group3
Horrible code to search for the difficult-to-deal-with commands:
gcm -Module azureadpreview |
% Parameters|
% getenumerator |
% Value |
group parametertype -NoElement |
sort name |
select Name, @{n='Type'; e={[type]($_.Name -replace '.*\[(.+)\]', '$1' -replace '\[\]' -split ',' | gu)}} |
select *, @{n='IsEnum'; e={$_.Type.IsEnum}} |
sort IsEnum,Type |
select *, @{n='ConstructableFrom'; e={$t = $_.Type; [hashtable], [int], [string], [datetime], [boolean], [enum], [object] |?{$t.GetConstructor(@($_))} }} |
select *, @{n='Constructors'; e={(("[$($_.Type)]::new"|iex).OverloadDefinitions)-notmatch'\(\)'-replace '.*\(','('}} |
ft -auto
# use judgement to determine the following difficult-to-deal-with types:
$DifficultTypes =
'Microsoft.Open.AzureAD.Model.AddIn',
'Microsoft.Open.AzureAD.Model.AlternativeSecurityId',
'Microsoft.Open.AzureAD.Model.AppRole',
'Microsoft.Open.AzureAD.Model.AssignedLicenses',
'Microsoft.Open.AzureAD.Model.CertificateAuthorityInformation',
'Microsoft.Open.AzureAD.Model.DomainFederationSettings',
'Microsoft.Open.AzureAD.Model.GroupIdsForMembershipCheck',
'Microsoft.Open.AzureAD.Model.InformationalUrl',
'Microsoft.Open.AzureAD.Model.KeyCredential',
'Microsoft.Open.AzureAD.Model.OAuth2Permission',
'Microsoft.Open.AzureAD.Model.PasswordCredential',
'Microsoft.Open.AzureAD.Model.PasswordProfile',
'Microsoft.Open.AzureAD.Model.PrivacyProfile',
'Microsoft.Open.AzureAD.Model.RequiredResourceAccess',
'Microsoft.Open.AzureAD.Model.RoleMemberInfo',
'Microsoft.Open.AzureAD.Model.SignInName',
'Microsoft.Open.MSGraph.Model.DirectorySetting',
'Microsoft.Open.MSGraph.Model.InvitedUserMessageInfo',
'Microsoft.Open.MSGraph.Model.KeyCredential'
gcm -Module azureadpreview |
?{!($_.ParameterSets |
?{ !($_.Parameters |?{ $_.ParameterType -in $DifficultTypes -and $_.IsMandatory }) })} |
select Name, @{n='Parameters'; e={
$_.ParameterSets.Parameters |?{ $_.ParameterType -in $DifficultTypes -and $_.IsMandatory} | % Name | gu}
}