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

Added new function, adjust functionality of cache clear and updated project help #1

Merged
merged 2 commits into from
Dec 1, 2023
Merged
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
3 changes: 2 additions & 1 deletion ResolveEntraID/ResolveEntraID.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
RootModule = 'ResolveEntraID.psm1'

# Version number of this module.
ModuleVersion = '1.0.1'
ModuleVersion = '1.1.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -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.
Expand Down
22 changes: 20 additions & 2 deletions ResolveEntraID/functions/Clear-MeidIdentityCache.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
6 changes: 4 additions & 2 deletions ResolveEntraID/functions/Resolve-MeidIdentity.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@
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.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)]
[AllowEmptyCollection()]
[AllowNull()]
[string[]]
$Id,

Expand Down Expand Up @@ -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
}
Expand Down
36 changes: 36 additions & 0 deletions ResolveEntraID/functions/Unregister-MeidIdentityProvider.ps1
Original file line number Diff line number Diff line change
@@ -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)
}
}
}
2 changes: 1 addition & 1 deletion ResolveEntraID/internal/scripts/2-tabexpansion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 ", ")
}
}
}
15 changes: 13 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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 |
| ----------- | ----------------- | ------------ |
Expand Down