diff --git a/ResolveEntraID/ResolveEntraID.psd1 b/ResolveEntraID/ResolveEntraID.psd1 index 15e0f3a..d584eb8 100644 --- a/ResolveEntraID/ResolveEntraID.psd1 +++ b/ResolveEntraID/ResolveEntraID.psd1 @@ -4,7 +4,7 @@ RootModule = 'ResolveEntraID.psm1' # Version number of this module. - ModuleVersion = '1.0.1' + ModuleVersion = '1.1.0' # Supported PSEditions # CompatiblePSEditions = @() @@ -69,6 +69,7 @@ 'Get-MeidIdentityProvider' 'Register-MeidIdentityProvider' 'Resolve-MeidIdentity' + 'Unregister-MeidIdentityProvider' ) # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. diff --git a/ResolveEntraID/functions/Clear-MeidIdentityCache.ps1 b/ResolveEntraID/functions/Clear-MeidIdentityCache.ps1 index 449fa77..4e4d7d9 100644 --- a/ResolveEntraID/functions/Clear-MeidIdentityCache.ps1 +++ b/ResolveEntraID/functions/Clear-MeidIdentityCache.ps1 @@ -5,13 +5,31 @@ .DESCRIPTION Clears the Microsoft Entra ID identiy cache. The cache is used to cache the mapping between the ID and resolved name. + + .PARAMETER Provider + Name(s) of provider, where the cache should be cleared. .EXAMPLE PS C:\> Clear-MeidIdentityCache Clears the Entra ID identiy cache. + + .EXAMPLE + PS C:\> Clear-MeidIdentityCache -Provider "UserUPN", "Group" + + Clears the Entra ID identiy cache of Providers "UserUPN", "Group". #> [CmdletBinding()] - param () - $script:IdNameMappingTable = @{} + param ( + [string[]] + $Provider + ) + if (-not $Provider) { + $script:IdNameMappingTable = @{} + } + else { + foreach ($providerName in $Provider){ + $script:IdNameMappingTable.Remove($providerName) + } + } } \ No newline at end of file diff --git a/ResolveEntraID/functions/Resolve-MeidIdentity.ps1 b/ResolveEntraID/functions/Resolve-MeidIdentity.ps1 index 2abad83..6842549 100644 --- a/ResolveEntraID/functions/Resolve-MeidIdentity.ps1 +++ b/ResolveEntraID/functions/Resolve-MeidIdentity.ps1 @@ -39,7 +39,7 @@ The written output is ID, Name (Property), Provider and the result will NOT be written in the cache. .EXAMPLE - PS C:\> Resolve-MeidIdentity -ID "xyz","abc" -Provider UserUPN,Group -NoCache + PS C:\> Resolve-MeidIdentity -ID "xyz","abc" -Provider UserUPN,Group -NoCache -NameOnly Will resolve the IDs "xyz" and "abc" with defined property in the providers "UserUPN" and "Group". The written output is only Name (Property) and the result will NOT be written in the cache. @@ -47,6 +47,8 @@ [CmdletBinding()] param ( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] + [AllowEmptyCollection()] + [AllowNull()] [string[]] $Id, @@ -146,7 +148,7 @@ continue main } catch { - if ($_.ErrorDetails.Message -match '"code":"Request_ResourceNotFound"') { + if ($_.ErrorDetails.Message -match '"code":\s*"Request_ResourceNotFound"') { Write-PSFMessage -Level InternalComment -Message "ID {0} could not found as {1}." -StringValues $entry, $providerName -Target $entry -Tag $providerName -ErrorRecord $_ -OverrideExceptionMessage continue } diff --git a/ResolveEntraID/functions/Unregister-MeidIdentityProvider.ps1 b/ResolveEntraID/functions/Unregister-MeidIdentityProvider.ps1 new file mode 100644 index 0000000..ddad2be --- /dev/null +++ b/ResolveEntraID/functions/Unregister-MeidIdentityProvider.ps1 @@ -0,0 +1,36 @@ +function Unregister-MeidIdentityProvider { + <# + .SYNOPSIS + Unregister Entra ID identity provider. + + .DESCRIPTION + Unregister Microsoft Entra ID identity provider. + + .PARAMETER ProviderName + Name of the provider that should be unregistered. + + .EXAMPLE + PS C:\> Unregister-MeidIdentityProvider -Name "UserUPN" + + Will unregister a provider with name "UserUPN". + + .EXAMPLE + PS C:\> Unregister-MeidIdentityProvider -Name "UserUPN", "Groups" + + Will unregister a provider with name "UserUPN" and "Groups". + #> + [CmdletBinding()] + param ( + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] + [PSFArgumentCompleter("ResolveEntraID.Provider")] + [PSFValidateSet(TabCompletion = "ResolveEntraID.Provider")] + [string[]] + $ProviderName + ) + process { + foreach ($entry in $ProviderName ){ + Clear-MeidIdentityCache -Provider $entry + $script:IdentityProvider.Remove($entry) + } + } +} \ No newline at end of file diff --git a/ResolveEntraID/internal/scripts/2-tabexpansion.ps1 b/ResolveEntraID/internal/scripts/2-tabexpansion.ps1 index 7e0b0cc..964a5df 100644 --- a/ResolveEntraID/internal/scripts/2-tabexpansion.ps1 +++ b/ResolveEntraID/internal/scripts/2-tabexpansion.ps1 @@ -2,7 +2,7 @@ foreach ($provider in Get-MeidIdentityProvider){ @{ Text = $provider.Name - ToolTip = "{0} --> {1}" -f $provider.Name, ($provider.NameProperty -join ", ") + ToolTip = "{0} --> Property: {1}" -f $provider.Name, ($provider.NameProperty -join ", ") } } } \ No newline at end of file diff --git a/readme.md b/readme.md index 32e58e8..dac7612 100644 --- a/readme.md +++ b/readme.md @@ -4,7 +4,7 @@ Welcome to the module toolkit designed to resolve IDs in Entra ID to needed properties. If you want to export the name of users, groups, applications or all other things in Entra ID, but you have only the IDs of these? -Just use this module, it will help you to resolbe the IDs to properties that YOU want! +Just use this module, it will help you to resolve the IDs to properties that YOU want! ## Installing @@ -21,6 +21,13 @@ Install-Module ResolveEntraID -Scope CurrentUser Register-MeidIdentityProvider -Name "UserUPN" -NameProperty "userPrincipalName" -Query "users" ``` +## Unregister Identity Provider + +```powershell +# Unregister a provider with name "UserUPN" and clear cache of the "UserUPN" provider. +Unregister-MeidIdentityProvider -Name "UserUPN" +``` + ## Get Identity Provider ```powershell @@ -46,8 +53,12 @@ Resolve-MeidIdentity -ID "xyz","abc" -Provider UserUPN,Group # Clears the Entra ID identiy cache. Clear-MeidIdentityCache ``` +```powershell +# Clears the Entra ID identiy cache of provider "UserUPN". +Clear-MeidIdentityCache -ProviderName "UserUPN" +``` -## Registered Provider by Default +## Registered Provider by default | Name | Property | Query | | ----------- | ----------------- | ------------ |