Skip to content

Commit

Permalink
fix: Handle nested attribute names in graph config file correctly ('o…
Browse files Browse the repository at this point in the history
…nPremisesExtensionAttributes.extensionAttribute1' et al.) (#41)
  • Loading branch information
GruberMarkus committed Jul 26, 2022
1 parent 1d155ac commit 1d3b8d5
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 12 deletions.
8 changes: 4 additions & 4 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
### Fixed
-->

## <a href="https://github.com/GruberMarkus/Set-OutlookSignatures/releases/tag/vx.x.x" target="_blank">vx.x.x</a> - YYYY-MM-DD
## <a href="https://github.com/GruberMarkus/Set-OutlookSignatures/releases/tag/v3.2.1-beta1" target="_blank">v3.2.1-beta1</a> - 2022-07-26
_Attention cloud mailbox users: Microsoft will make roaming signatures available in late 2022. See 'What about the roaming signatures feature announced by Microsoft?' in README for details and recommended preparation steps._
### Changed
- The permission check no longer shows all allow or deny reasons, only the first match. The deny part is no longer evaluated when no allow match has been found.
### Fixed
- Template file categorization time grew exponentially with each template appearing multiple times in the INI file
- The permission check no longer takes more time than necessary by showing all allow or deny reasons, only the first match. Denies are only evaluated when an allow match has been found before.
- Template file categorization time no longer grows exponentially with each template appearing multiple times in the INI file
- Handle nested attribute names in graph config file correctly ('onPremisesExtensionAttributes.extensionAttribute1' et al.) (<a href="https://github.com/GruberMarkus/Set-OutlookSignatures/issues/41" target="_blank">#41</a>) (Thanks <a href="https://github.com/dakolta" target="_blank">@dakolta</a>!)

## <a href="https://github.com/GruberMarkus/Set-OutlookSignatures/releases/tag/v3.2.0" target="_blank">v3.2.0</a> - 2022-07-19
_Attention cloud mailbox users: Microsoft will make roaming signatures available in late 2022. See 'What about the roaming signatures feature announced by Microsoft?' in README for details and recommended preparation steps._
Expand Down
51 changes: 43 additions & 8 deletions src/Set-OutlookSignatures.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -863,11 +863,20 @@ function main {
if ($x.error -eq $false) {
$AADProps = $x.properties
$ADPropsCurrentUser = [PSCustomObject]@{}
foreach ($x in $GraphUserAttributeMapping.GetEnumerator()) {
$ADPropsCurrentUser | Add-Member -MemberType NoteProperty -Name ($x.Name) -Value ($AADProps.($x.value))

foreach ($GraphUserAttributeMappingName in $GraphUserAttributeMapping.GetEnumerator()) {
$z = $AADProps

foreach ($y in ($GraphUserAttributeMappingName.value -split '\.')) {
$z = $z.$y
}

$ADPropsCurrentUser | Add-Member -MemberType NoteProperty -Name ($GraphUserAttributeMappingName.Name) -Value $z
}

$ADPropsCurrentUser | Add-Member -MemberType NoteProperty -Name 'thumbnailphoto' -Value (GraphGetUserPhoto $script:CurrentUser).photo
$ADPropsCurrentUser | Add-Member -MemberType NoteProperty -Name 'manager' -Value (GraphGetUserManager $script:CurrentUser).properties.userprincipalname

} else {
Write-Host " Problem getting data for '$($script:CurrentUser)' from Microsoft Graph. Exit." -ForegroundColor Red
$error[0]
Expand Down Expand Up @@ -948,9 +957,17 @@ function main {
if ($ADPropsCurrentUser.manager) {
$AADProps = (GraphGetUserProperties $ADPropsCurrentUser.manager).properties
$ADPropsCurrentUserManager = [PSCustomObject]@{}
foreach ($x in $GraphUserAttributeMapping.GetEnumerator()) {
$ADPropsCurrentUserManager | Add-Member -MemberType NoteProperty -Name ($x.Name) -Value ($AADProps.($x.value))

foreach ($GraphUserAttributeMappingName in $GraphUserAttributeMapping.GetEnumerator()) {
$z = $AADProps

foreach ($y in ($GraphUserAttributeMappingName.value -split '\.')) {
$z = $z.$y
}

$ADPropsCurrentUserManager | Add-Member -MemberType NoteProperty -Name ($GraphUserAttributeMappingName.Name) -Value $z
}

$ADPropsCurrentUserManager | Add-Member -MemberType NoteProperty -Name 'thumbnailphoto' -Value (GraphGetUserPhoto $ADPropsCurrentUserManager.userprincipalname).photo
$ADPropsCurrentUserManager | Add-Member -MemberType NoteProperty -Name 'manager' -Value $null
}
Expand Down Expand Up @@ -1022,11 +1039,20 @@ function main {
}
} else {
$AADProps = (GraphGetUserProperties $($MailAddresses[$AccountNumberRunning])).properties

$ADPropsMailboxes[$AccountNumberRunning] = [PSCustomObject]@{}

if ($AADProps) {
foreach ($x in $GraphUserAttributeMapping.GetEnumerator()) {
$ADPropsMailboxes[$AccountNumberRunning] | Add-Member -MemberType NoteProperty -Name ($x.Name) -Value ($AADProps.($x.value))
foreach ($GraphUserAttributeMappingName in $GraphUserAttributeMapping.GetEnumerator()) {
$z = $AADProps

foreach ($y in ($GraphUserAttributeMappingName.value -split '\.')) {
$z = $z.$y
}

$ADPropsMailboxes[$AccountNumberRunning] | Add-Member -MemberType NoteProperty -Name ($GraphUserAttributeMappingName.Name) -Value $z
}

$ADPropsMailboxes[$AccountNumberRunning] | Add-Member -MemberType NoteProperty -Name 'thumbnailphoto' -Value (GraphGetUserPhoto $ADPropsMailboxes[$AccountNumberRunning].userprincipalname).photo
$ADPropsMailboxes[$AccountNumberRunning] | Add-Member -MemberType NoteProperty -Name 'manager' -Value (GraphGetUserManager $ADPropsMailboxes[$AccountNumberRunning].userprincipalname).properties.userprincipalname
$LegacyExchangeDNs[$AccountNumberRunning] = 'dummy'
Expand Down Expand Up @@ -1653,10 +1679,19 @@ function main {
$AADProps = $null
if ($ADPropsCurrentMailbox.manager) {
$AADProps = (GraphGetUserProperties $ADPropsCurrentMailbox.manager).properties

$ADPropsCurrentMailboxManager = [PSCustomObject]@{}
foreach ($x in $GraphUserAttributeMapping.GetEnumerator()) {
$ADPropsCurrentMailboxManager | Add-Member -MemberType NoteProperty -Name ($x.Name) -Value ($AADProps.($x.value))

foreach ($GraphUserAttributeMappingName in $GraphUserAttributeMapping.GetEnumerator()) {
$z = $AADProps

foreach ($y in ($GraphUserAttributeMappingName.value -split '\.')) {
$z = $z.$y
}

$ADPropsCurrentMailboxManager | Add-Member -MemberType NoteProperty -Name ($GraphUserAttributeMappingName.Name) -Value $z
}

$ADPropsCurrentMailboxManager | Add-Member -MemberType NoteProperty -Name 'thumbnailphoto' -Value (GraphGetUserPhoto $ADPropsCurrentMailboxManager.userprincipalname).photo
$ADPropsCurrentMailboxManager | Add-Member -MemberType NoteProperty -Name 'manager' -Value $null
}
Expand Down

0 comments on commit 1d3b8d5

Please sign in to comment.