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

Add support to use function endsWith as filter #3519

Merged
merged 4 commits into from
Jul 27, 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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

# UNRELEASED

* AADGroup, AADUser and O365Group
* Add support to use function endsWith as filter
FIXES [#3518](https://github.com/microsoft/Microsoft365DSC/issues/3518)
* O365OrgSettings
* Added error handling for the Viva settings to handle task cancelation errors.
* Added error handling for the Viva settings to handle task cancellation errors.
* MISC
* M365DscReverse: Fix exporting when $Filter var exists locally
FIXES [#3515](https://github.com/microsoft/Microsoft365DSC/issues/3515)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,16 @@ function Export-TargetResource
try
{
$Script:ExportMode = $true
[array] $Script:exportedGroups = Get-MgGroup -Filter $Filter -All:$true -ErrorAction Stop
$ExportParameters = @{
Filter = $Filter
All = [switch]$true
ErrorAction = 'Stop'
}
if ($Filter -like "*endsWith*") {
$ExportParameters.Add('CountVariable', 'count')
$ExportParameters.Add('ConsistencyLevel', 'eventual')
}
[array] $Script:exportedGroups = Get-MgGroup @ExportParameters
$Script:exportedGroups = $Script:exportedGroups | Where-Object -FilterScript {
-not ($_.MailEnabled -and ($null -eq $_.GroupTypes -or $_.GroupTypes.Length -eq 0)) -and `
-not ($_.MailEnabled -and $_.SecurityEnabled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,17 @@ function Export-TargetResource
{
$Script:ExportMode = $true
$propertiesToRetrieve = @('Id', 'UserPrincipalName', 'DisplayName', 'GivenName', 'Surname', 'UsageLocation', 'City', 'Country', 'Department', 'FacsimileTelephoneNumber', 'Mobile', 'OfficeLocation', 'TelephoneNumber', 'PostalCode', 'PreferredLanguage', 'State', 'StreetAddress', 'JobTitle', 'UserType', 'PasswordPolicies')
$Script:M365DSCExportInstances = Get-MgUser -Filter $Filter -All:$true -Property $propertiesToRetrieve -ErrorAction Stop
$ExportParameters = @{
Filter = $Filter
All = [switch]$true
Property = $propertiesToRetrieve
ErrorAction = 'Stop'
}
if ($Filter -like "*endsWith*") {
$ExportParameters.Add('CountVariable', 'count')
$ExportParameters.Add('ConsistencyLevel', 'eventual')
}
$Script:M365DSCExportInstances = Get-MgUser @ExportParameters

$dscContent = [System.Text.StringBuilder]::new()
$i = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,16 @@ function Export-TargetResource
try
{
$dscContent = ''
$groups = Get-MgGroup -All:$true -Filter $Filter | Where-Object -FilterScript {
$ExportParameters = @{
Filter = $Filter
All = [switch]$true
ErrorAction = 'Stop'
}
if ($Filter -like "*endsWith*") {
$ExportParameters.Add('CountVariable', 'count')
$ExportParameters.Add('ConsistencyLevel', 'eventual')
}
$groups = Get-MgGroup @ExportParameters | Where-Object -FilterScript {
$_.MailNickName -ne '00000000-0000-0000-0000-000000000000'
}

Expand Down