Skip to content

Commit

Permalink
Merge branch 'Dev' into fix5505
Browse files Browse the repository at this point in the history
  • Loading branch information
NikCharlebois authored Dec 4, 2024
2 parents 2fea7da + a3c4f63 commit c74177c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
* AADClaimsMappingPolicy
* Fixed policy retrieval
FIXES [#5505](https://github.com/microsoft/Microsoft365DSC/issues/5505)
* AADIdentityAPIConnector
* Changed the export logic to export passwords as credential objects instead of string.
* AADRoleManagementPolicyRule
* Added the logic to handle filters in the Export logic flow.
* EXOAuthenticationPolicyAssignment
Expand All @@ -20,6 +22,8 @@
* Added $confirm flag to the Set-TargetResource function for PowerShell 7 compatibility.
* EXOManagementRoleAssignment
* Changed logic to detect drift.
* EXOServicePrincipal
* Removed ObjectID from the return of the Get-TargetResource method.
* EXOTeamsProtectionPolicy
* Initial release
FIXES [#5296](https://github.com/microsoft/Microsoft365DSC/issues/5296)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ function Get-TargetResource
foreach ($currentCertificate in $getValue.AuthenticationConfiguration.AdditionalProperties.certificateList)
{
$myCertificate = @{}
$myCertificate.Add('Pkcs12Value', 'Please insert a valid Pkcs12Value')
$myCertificate.Add('Pkcs12Value', "New-Object System.Management.Automation.PSCredential('Password', (ConvertTo-SecureString ('Please insert a valid Pkcs12Value') -AsPlainText -Force))")
$myCertificate.Add('Thumbprint', $currentCertificate.thumbprint)
$myCertificate.Add('Password', 'Please insert a valid Password for the certificate')
$myCertificate.Add('Password', "New-Object System.Management.Automation.PSCredential('Password', (ConvertTo-SecureString ('Please insert a valid Password for the certificate') -AsPlainText -Force))")
$myCertificate.Add('IsActive', $currentCertificate.isActive)

if ($myCertificate.values.Where({ $null -ne $_ }).Count -gt 0)
Expand Down Expand Up @@ -661,6 +661,11 @@ function Export-TargetResource
}
foreach ($config in $getValue)
{
if ($null -ne $Global:M365DSCExportResourceInstancesCount)
{
$Global:M365DSCExportResourceInstancesCount++
}

$displayedKey = $config.Id
if (-not [String]::IsNullOrEmpty($config.displayName))
{
Expand All @@ -685,12 +690,11 @@ function Export-TargetResource
}

$Results = Get-TargetResource @Params
$Results.Password = 'Please insert a valid Password'
$Results.Password = "New-Object System.Management.Automation.PSCredential('Password', (ConvertTo-SecureString ('Please insert a valid Password') -AsPlainText -Force));"

$Results = Update-M365DSCExportAuthenticationResults -ConnectionMode $ConnectionMode `
-Results $Results


if ($null -ne $Results.Certificates)
{
$complexTypeStringResult = Get-M365DSCDRGComplexTypeToString `
Expand Down Expand Up @@ -718,6 +722,13 @@ function Export-TargetResource
$currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName 'Certificates' -IsCIMArray:$True
}

# Replace the main password variable.
$currentDSCBlock = $currentDSCBlock.Replace('"New-Object System.', 'New-Object System.').Replace(') -AsPlainText -Force));";', ') -AsPlainText -Force));')

# Replace the certificate variables.
$currentDSCBlock = $currentDSCBlock.Replace("'New-Object System.", "New-Object System.").Replace(" -Force))'", " -Force))")
$currentDSCBlock = $currentDSCBlock.Replace("(ConvertTo-SecureString (''", "(ConvertTo-SecureString ('").Replace("''Password''", "'Password'").Replace("'') -AsPlainText", "') -AsPlainText")

$dscContent += $currentDSCBlock
Save-M365DSCPartialExport -Content $currentDSCBlock `
-FileName $Global:PartialExportFileName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ function Get-TargetResource
AppName = $servicePrincipal.AppDisplayName
DisplayName = $instance.DisplayName
AppId = $instance.AppId
ObjectId = $instance.ObjectId
Ensure = 'Present'
Credential = $Credential
ApplicationId = $ApplicationId
Expand Down Expand Up @@ -195,7 +194,6 @@ function Set-TargetResource
elseif ($Ensure -eq 'Present' -and $currentInstance.Ensure -eq 'Present')
{
$setParameters.Remove('AppId')
$setParameters.Remove('ObjectId')
Set-ServicePrincipal -DisplayName $DisplayName -Identity $servicePrincipal.Id
}
# REMOVE
Expand Down Expand Up @@ -354,6 +352,11 @@ function Export-TargetResource
}
foreach ($config in $Script:exportedInstances)
{
if ($null -ne $Global:M365DSCExportResourceInstancesCount)
{
$Global:M365DSCExportResourceInstancesCount++
}

$servicePrincipal = Get-MgServicePrincipal -ServicePrincipalId $config.Identity

$displayedKey = $servicePrincipal.AppDisplayName
Expand Down

0 comments on commit c74177c

Please sign in to comment.