From cdcbbd573d19532060d003ba4fc494a71808aa6a Mon Sep 17 00:00:00 2001 From: Alfred Schreuder Date: Wed, 11 Dec 2024 16:06:01 +0100 Subject: [PATCH 1/9] Fix policy creation bug --- ...alAdministratorPasswordSolutionPolicy.psm1 | 49 ++++++++++------- ...ntuneAccountProtectionPolicyWindows10.psm1 | 49 ++++++++++------- .../MSFT_IntuneAntivirusPolicyLinux.psm1 | 49 ++++++++++------- .../MSFT_IntuneAntivirusPolicyMacOS.psm1 | 49 ++++++++++------- ...ntivirusPolicyWindows10SettingCatalog.psm1 | 49 ++++++++++------- ...AppAndBrowserIsolationPolicyWindows10.psm1 | 49 ++++++++++------- ...FT_IntuneDeviceControlPolicyWindows10.psm1 | 49 ++++++++++------- .../MSFT_IntuneDiskEncryptionMacOS.psm1 | 52 +++++++++++-------- .../MSFT_IntuneDiskEncryptionWindows10.psm1 | 48 ++++++++++------- ...dpointDetectionAndResponsePolicyLinux.psm1 | 49 ++++++++++------- ...dpointDetectionAndResponsePolicyMacOS.psm1 | 49 ++++++++++------- ...ntDetectionAndResponsePolicyWindows10.psm1 | 45 ++++++++++------ .../MSFT_IntuneFirewallPolicyWindows10.psm1 | 49 ++++++++++------- ...SettingCatalogASRRulesPolicyWindows10.psm1 | 49 ++++++++++------- 14 files changed, 419 insertions(+), 265 deletions(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.psm1 index 096e29a19d..fe51e6dbd5 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.psm1 @@ -129,34 +129,47 @@ function Get-TargetResource Add-M365DSCTelemetryEvent -Data $data #endregion - $nullResult = $PSBoundParameters - $nullResult.Ensure = 'Absent' - + #Retrieve policy general settings $templateReferenceId = 'adc46e5a-f4aa-4ff6-aeff-4f27bc525796_1' - # Retrieve policy general settings - $policy = $null - $policy = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Identity -ErrorAction SilentlyContinue - - if ($null -eq $policy) + if ($PSBoundParameters.ContainsKey('Identity')) { - Write-Verbose -Message "No Account Protection LAPS Policy with Id {$Identity} was found" - - if (-not [System.String]::IsNullOrEmpty($DisplayName)) + Write-Verbose -Message 'PolicyID was specified' + try { - $policy = Get-MgBetaDeviceManagementConfigurationPolicy ` - -Filter "Name eq '$DisplayName' and templateReference/TemplateId eq '$templateReferenceId'" ` - -ErrorAction SilentlyContinue + $policy = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Identity -ErrorAction Stop + } + catch + { + Write-Verbose -Message "Couldn't find existing policy by ID {$Identity}" + $policy = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName' and templateReference/TemplateId eq '$templateReferenceId'" + if ($policy.Length -gt 1) + { + throw "Duplicate Account Protection LAPS Policyy named $DisplayName exist in tenant" + } + } + } + else + { + Write-Verbose -Message 'Id was NOT specified' + ## Can retreive multiple Intune Policies since displayname is not unique + $policy = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName' and templateReference/TemplateId eq '$templateReferenceId'" + if ($policy.Length -gt 1) + { + throw "Duplicate Account Protection LAPS Policy named $DisplayName exist in tenant" } } - if ($null -eq $policy) + if ([String]::IsNullOrEmpty($policy.id)) { - Write-Verbose -Message "No Account Protection LAPS Policy with Name {$DisplayName} was found" - return $nullResult + Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + $currentValues = $PSBoundParameters + $currentValues.Ensure = 'Absent' + return $currentValues } + $Identity = $policy.Id - Write-Verbose "Found Account Protection LAPS Policy with Id {$Identity} and Name {$($policy.Name)}" + Write-Verbose -Message "An Account Protection LAPS Policy with Id {$Identity} and Name {$DisplayName} was found" [array]$settings = Get-MgBetaDeviceManagementConfigurationPolicySetting ` -DeviceManagementConfigurationPolicyId $Identity ` diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionPolicyWindows10/MSFT_IntuneAccountProtectionPolicyWindows10.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionPolicyWindows10/MSFT_IntuneAccountProtectionPolicyWindows10.psm1 index dbf21af696..9360029c10 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionPolicyWindows10/MSFT_IntuneAccountProtectionPolicyWindows10.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionPolicyWindows10/MSFT_IntuneAccountProtectionPolicyWindows10.psm1 @@ -85,31 +85,42 @@ function Get-TargetResource Add-M365DSCTelemetryEvent -Data $data #endregion - $nullResult = $PSBoundParameters - $nullResult.Ensure = 'Absent' - - $getValue = $null - #region resource generator code - $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Id -ErrorAction SilentlyContinue - - if ($null -eq $getValue) + if ($PSBoundParameters.ContainsKey('Id')) { - Write-Verbose -Message "Could not find an Intune Account Protection Policy for Windows10 with Id {$Id}" - - if (-not [System.String]::IsNullOrEmpty($DisplayName)) + Write-Verbose -Message 'PolicyID was specified' + try + { + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Id -ErrorAction Stop + } + catch + { + Write-Verbose -Message "Couldn't find existing policy by ID {$Id}" + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" + if ($getValue.Length -gt 1) + { + throw "Duplicate Intune Account Protection Policy for Windows10 named $DisplayName exist in tenant" + } + } + } + else + { + Write-Verbose -Message 'Id was NOT specified' + ## Can retreive multiple Intune Policies since displayname is not unique + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" + if ($getValue.Length -gt 1) { - $getValue = Get-MgBetaDeviceManagementConfigurationPolicy ` - -All ` - -Filter "Name eq '$DisplayName'" ` - -ErrorAction SilentlyContinue + throw "Duplicate Intune Account Protection Policy for Windows10 named $DisplayName exist in tenant" } } - #endregion - if ($null -eq $getValue) + + if ([String]::IsNullOrEmpty($getValue.id)) { - Write-Verbose -Message "Could not find an Intune Account Protection Policy for Windows10 with Name {$DisplayName}." - return $nullResult + Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + $currentValues = $PSBoundParameters + $currentValues.Ensure = 'Absent' + return $currentValues } + $Id = $getValue.Id Write-Verbose -Message "An Intune Account Protection Policy for Windows10 with Id {$Id} and Name {$DisplayName} was found" diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyLinux/MSFT_IntuneAntivirusPolicyLinux.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyLinux/MSFT_IntuneAntivirusPolicyLinux.psm1 index cc250b27ab..d5bf54a020 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyLinux/MSFT_IntuneAntivirusPolicyLinux.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyLinux/MSFT_IntuneAntivirusPolicyLinux.psm1 @@ -192,31 +192,42 @@ function Get-TargetResource Add-M365DSCTelemetryEvent -Data $data #endregion - $nullResult = $PSBoundParameters - $nullResult.Ensure = 'Absent' - - $getValue = $null - #region resource generator code - $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Id -ErrorAction SilentlyContinue - - if ($null -eq $getValue) + if ($PSBoundParameters.ContainsKey('Id')) { - Write-Verbose -Message "Could not find an Intune Antivirus Policy for Linux with Id {$Id}" - - if (-not [System.String]::IsNullOrEmpty($DisplayName)) + Write-Verbose -Message 'PolicyID was specified' + try + { + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Id -ErrorAction Stop + } + catch + { + Write-Verbose -Message "Couldn't find existing policy by ID {$Id}" + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" + if ($getValue.Length -gt 1) + { + throw "Duplicate Intune Antivirus Policy for Linux named $DisplayName exist in tenant" + } + } + } + else + { + Write-Verbose -Message 'Id was NOT specified' + ## Can retreive multiple Intune Policies since displayname is not unique + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" + if ($getValue.Length -gt 1) { - $getValue = Get-MgBetaDeviceManagementConfigurationPolicy ` - -All ` - -Filter "Name eq '$DisplayName'" ` - -ErrorAction SilentlyContinue + throw "Duplicate Intune Antivirus Policy for Linux named $DisplayName exist in tenant" } } - #endregion - if ($null -eq $getValue) + + if ([String]::IsNullOrEmpty($getValue.id)) { - Write-Verbose -Message "Could not find an Intune Antivirus Policy for Linux with Name {$DisplayName}." - return $nullResult + Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + $currentValues = $PSBoundParameters + $currentValues.Ensure = 'Absent' + return $currentValues } + $Id = $getValue.Id Write-Verbose -Message "An Intune Antivirus Policy for Linux with Id {$Id} and Name {$DisplayName} was found" diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyMacOS/MSFT_IntuneAntivirusPolicyMacOS.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyMacOS/MSFT_IntuneAntivirusPolicyMacOS.psm1 index 30829e2aab..a844a3c8bb 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyMacOS/MSFT_IntuneAntivirusPolicyMacOS.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyMacOS/MSFT_IntuneAntivirusPolicyMacOS.psm1 @@ -195,31 +195,42 @@ function Get-TargetResource Add-M365DSCTelemetryEvent -Data $data #endregion - $nullResult = $PSBoundParameters - $nullResult.Ensure = 'Absent' - - $getValue = $null - #region resource generator code - $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Id -ErrorAction SilentlyContinue - - if ($null -eq $getValue) + if ($PSBoundParameters.ContainsKey('Id')) { - Write-Verbose -Message "Could not find an Intune Antivirus Policy for macOS with Id {$Id}" - - if (-not [System.String]::IsNullOrEmpty($DisplayName)) + Write-Verbose -Message 'PolicyID was specified' + try + { + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Id -ErrorAction Stop + } + catch + { + Write-Verbose -Message "Couldn't find existing policy by ID {$Id}" + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" + if ($getValue.Length -gt 1) + { + throw "Duplicate Intune Antivirus Policy for macOS named $DisplayName exist in tenant" + } + } + } + else + { + Write-Verbose -Message 'Id was NOT specified' + ## Can retreive multiple Intune Policies since displayname is not unique + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" + if ($getValue.Length -gt 1) { - $getValue = Get-MgBetaDeviceManagementConfigurationPolicy ` - -Filter "Name eq '$DisplayName'" ` - -All ` - -ErrorAction SilentlyContinue + throw "Duplicate Intune Antivirus Policy for macOS named $DisplayName exist in tenant" } } - #endregion - if ($null -eq $getValue) + + if ([String]::IsNullOrEmpty($getValue.id)) { - Write-Verbose -Message "Could not find an Intune Antivirus Policy for macOS with Name {$DisplayName}." - return $nullResult + Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + $currentValues = $PSBoundParameters + $currentValues.Ensure = 'Absent' + return $currentValues } + $Id = $getValue.Id Write-Verbose -Message "An Intune Antivirus Policy for macOS with Id {$Id} and Name {$DisplayName} was found" diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyWindows10SettingCatalog/MSFT_IntuneAntivirusPolicyWindows10SettingCatalog.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyWindows10SettingCatalog/MSFT_IntuneAntivirusPolicyWindows10SettingCatalog.psm1 index 3ca3c511c6..79ce7692b0 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyWindows10SettingCatalog/MSFT_IntuneAntivirusPolicyWindows10SettingCatalog.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyWindows10SettingCatalog/MSFT_IntuneAntivirusPolicyWindows10SettingCatalog.psm1 @@ -439,37 +439,46 @@ function Get-TargetResource Add-M365DSCTelemetryEvent -Data $data #endregion - $nullResult = $PSBoundParameters - $nullResult.Ensure = 'Absent' - $templateReferences = 'd948ff9b-99cb-4ee0-8012-1fbc09685377_1', 'e3f74c5a-a6de-411d-aef6-eb15628f3a0a_1', '45fea5e9-280d-4da1-9792-fb5736da0ca9_1', '804339ad-1553-4478-a742-138fb5807418_1' - #Retrieve policy general settings - $policy = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Identity -ErrorAction SilentlyContinue - - if ($null -eq $policy) + if ($PSBoundParameters.ContainsKey('Identity')) { - Write-Verbose -Message "Could not find an Intune Antivirus Policy for Windows10 Setting Catalog with Id {$Identity}" - - if (-not [System.String]::IsNullOrEmpty($DisplayName)) + Write-Verbose -Message 'PolicyID was specified' + try { - $policy = Get-MgBetaDeviceManagementConfigurationPolicy ` - -All ` - -Filter "Name eq '$DisplayName'" ` - -ErrorAction SilentlyContinue | Where-Object ` - -FilterScript { - $_.TemplateReference.TemplateId -in $templateReferences + $policy = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Identity -ErrorAction Stop + } + catch + { + Write-Verbose -Message "Couldn't find existing policy by ID {$Identity}" + $policy = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" | Where-Object -FilterScript {$_.TemplateReference.TemplateId -in $templateReferences} + if ($policy.Length -gt 1) + { + throw "Duplicate Intune Antivirus Policy for Windows10 Setting Catalog named $DisplayName exist in tenant" } } } + else + { + Write-Verbose -Message 'Id was NOT specified' + ## Can retreive multiple Intune Policies since displayname is not unique + $policy = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" + if ($policy.Length -gt 1) + { + throw "Duplicate Intune Antivirus Policy for Windows10 Setting Catalog named $DisplayName exist in tenant" + } + } - if ($null -eq $policy) + if ([String]::IsNullOrEmpty($policy.Id)) { - Write-Verbose -Message "Could not find an Intune Antivirus Policy for Windows10 Setting Catalog with Name {$DisplayName}" - return $nullResult + Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + $currentValues = $PSBoundParameters + $currentValues.Ensure = 'Absent' + return $currentValues } + $Identity = $policy.Id - Write-Verbose -Message "An Intune Antivirus Policy for Windows10 Setting Catalog with Id {$Identity} and Name {$DisplayName} was found." + Write-Verbose -Message "An Intune Antivirus Policy for Windows10 Setting Catalog with Id {$Identity} and Name {$DisplayName} was found" #Retrieve policy specific settings [array]$settings = Get-MgBetaDeviceManagementConfigurationPolicySetting ` diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAppAndBrowserIsolationPolicyWindows10/MSFT_IntuneAppAndBrowserIsolationPolicyWindows10.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAppAndBrowserIsolationPolicyWindows10/MSFT_IntuneAppAndBrowserIsolationPolicyWindows10.psm1 index 6428046d92..8d8be2e444 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAppAndBrowserIsolationPolicyWindows10/MSFT_IntuneAppAndBrowserIsolationPolicyWindows10.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAppAndBrowserIsolationPolicyWindows10/MSFT_IntuneAppAndBrowserIsolationPolicyWindows10.psm1 @@ -165,31 +165,42 @@ function Get-TargetResource Add-M365DSCTelemetryEvent -Data $data #endregion - $nullResult = $PSBoundParameters - $nullResult.Ensure = 'Absent' - - $getValue = $null - #region resource generator code - $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Id -ErrorAction SilentlyContinue - - if ($null -eq $getValue) + if ($PSBoundParameters.ContainsKey('Id')) { - Write-Verbose -Message "Could not find an Intune App And Browser Isolation Policy for Windows10 with Id {$Id}" - - if (-not [System.String]::IsNullOrEmpty($DisplayName)) + Write-Verbose -Message 'PolicyID was specified' + try + { + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Id -ErrorAction Stop + } + catch + { + Write-Verbose -Message "Couldn't find existing policy by ID {$Id}" + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" + if ($getValue.Length -gt 1) + { + throw "Duplicate Intune App And Browser Isolation Policy for Windows10 named $DisplayName exist in tenant" + } + } + } + else + { + Write-Verbose -Message 'Id was NOT specified' + ## Can retreive multiple Intune Policies since displayname is not unique + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" + if ($getValue.Length -gt 1) { - $getValue = Get-MgBetaDeviceManagementConfigurationPolicy ` - -All ` - -Filter "Name eq '$DisplayName'" ` - -ErrorAction SilentlyContinue + throw "Duplicate Intune App And Browser Isolation Policy for Windows10 named $DisplayName exist in tenant" } } - #endregion - if ($null -eq $getValue) + + if ([String]::IsNullOrEmpty($getValue.id)) { - Write-Verbose -Message "Could not find an Intune App And Browser Isolation Policy for Windows10 with Name {$DisplayName}." - return $nullResult + Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + $currentValues = $PSBoundParameters + $currentValues.Ensure = 'Absent' + return $currentValues } + $Id = $getValue.Id Write-Verbose -Message "An Intune App And Browser Isolation Policy for Windows10 with Id {$Id} and Name {$DisplayName} was found" diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDeviceControlPolicyWindows10/MSFT_IntuneDeviceControlPolicyWindows10.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDeviceControlPolicyWindows10/MSFT_IntuneDeviceControlPolicyWindows10.psm1 index cefaba98a3..0d8094acd2 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDeviceControlPolicyWindows10/MSFT_IntuneDeviceControlPolicyWindows10.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDeviceControlPolicyWindows10/MSFT_IntuneDeviceControlPolicyWindows10.psm1 @@ -251,31 +251,42 @@ function Get-TargetResource Add-M365DSCTelemetryEvent -Data $data #endregion - $nullResult = $PSBoundParameters - $nullResult.Ensure = 'Absent' - - $getValue = $null - #region resource generator code - $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Id -ErrorAction SilentlyContinue - - if ($null -eq $getValue) + if ($PSBoundParameters.ContainsKey('Id')) { - Write-Verbose -Message "Could not find an Intune Device Control Policy for Windows10 with Id {$Id}" - - if (-not [System.String]::IsNullOrEmpty($DisplayName)) + Write-Verbose -Message 'PolicyID was specified' + try + { + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Id -ErrorAction Stop + } + catch + { + Write-Verbose -Message "Couldn't find existing policy by ID {$Id}" + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" + if ($getValue.Length -gt 1) + { + throw "Duplicate Intune Device Control Policy for Windows10 named $DisplayName exist in tenant" + } + } + } + else + { + Write-Verbose -Message 'Id was NOT specified' + ## Can retreive multiple Intune Policies since displayname is not unique + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" + if ($getValue.Length -gt 1) { - $getValue = Get-MgBetaDeviceManagementConfigurationPolicy ` - -All ` - -Filter "Name eq '$DisplayName'" ` - -ErrorAction SilentlyContinue + throw "Duplicate Intune Device Control Policy for Windows10 named $DisplayName exist in tenant" } } - #endregion - if ($null -eq $getValue) + + if ([String]::IsNullOrEmpty($getValue.id)) { - Write-Verbose -Message "Could not find an Intune Device Control Policy for Windows10 with Name {$DisplayName}." - return $nullResult + Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + $currentValues = $PSBoundParameters + $currentValues.Ensure = 'Absent' + return $currentValues } + $Id = $getValue.Id Write-Verbose -Message "An Intune Device Control Policy for Windows10 with Id {$Id} and Name {$DisplayName} was found" diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDiskEncryptionMacOS/MSFT_IntuneDiskEncryptionMacOS.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDiskEncryptionMacOS/MSFT_IntuneDiskEncryptionMacOS.psm1 index 282ecce2df..bf084c61ac 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDiskEncryptionMacOS/MSFT_IntuneDiskEncryptionMacOS.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDiskEncryptionMacOS/MSFT_IntuneDiskEncryptionMacOS.psm1 @@ -112,36 +112,44 @@ function Get-TargetResource Add-M365DSCTelemetryEvent -Data $data #endregion - $nullResult = $PSBoundParameters - $nullResult.Ensure = 'Absent' - - $getValue = $null - #region resource generator code - $getValue = Get-MgBetaDeviceManagementIntent -DeviceManagementIntentId $Id -ErrorAction SilentlyContinue - - if ($null -eq $getValue) + if ($PSBoundParameters.ContainsKey('Id')) { - Write-Verbose -Message "Could not find an Intune Disk Encryption for macOS with Id {$Id}" - - if (-Not [string]::IsNullOrEmpty($DisplayName)) + Write-Verbose -Message 'PolicyID was specified' + try { - $getValue = Get-MgBetaDeviceManagementIntent ` - -All ` - -Filter "DisplayName eq '$DisplayName'" ` - -ErrorAction SilentlyContinue | Where-Object ` - -FilterScript { ` - $_.TemplateId -eq 'a239407c-698d-4ef8-b314-e3ae409204b8' ` + $getValue = Get-MgBetaDeviceManagementIntent -DeviceManagementIntentId $Id -ErrorAction Stop + } + catch + { + Write-Verbose -Message "Couldn't find existing policy by ID {$Id}" + $getValue = Get-MgBetaDeviceManagementIntent -All -Filter "DisplayName eq '$DisplayName'" | Where-Object -FilterScript {$_.TemplateId -eq 'a239407c-698d-4ef8-b314-e3ae409204b8'} + if ($getValue.Length -gt 1) + { + throw "Duplicate Intune Disk Encryption for macOS named $DisplayName exist in tenant" } } } - #endregion - if ($null -eq $getValue) + else { - Write-Verbose -Message "Could not find an Intune Disk Encryption for macOS with DisplayName {$DisplayName}" - return $nullResult + Write-Verbose -Message 'Id was NOT specified' + ## Can retreive multiple Intune Policies since displayname is not unique + $getValue = Get-MgBetaDeviceManagementIntent -All -Filter "DisplayName eq '$DisplayName'" | Where-Object -FilterScript {$_.TemplateId -eq 'a239407c-698d-4ef8-b314-e3ae409204b8'} + if ($getValue.Length -gt 1) + { + throw "Duplicate Intune Disk Encryption for macOS named $DisplayName exist in tenant" + } } + + if ([String]::IsNullOrEmpty($getValue.id)) + { + Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + $currentValues = $PSBoundParameters + $currentValues.Ensure = 'Absent' + return $currentValues + } + $Id = $getValue.Id - Write-Verbose -Message "An Intune Disk Encryption for macOS with Id {$Id} and DisplayName {$DisplayName} was found." + Write-Verbose -Message "An Intune Disk Encryption for macOS with Id {$Id} and Name {$DisplayName} was found" #Retrieve policy specific settings [array]$settings = Get-MgBetaDeviceManagementIntentSetting ` diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDiskEncryptionWindows10/MSFT_IntuneDiskEncryptionWindows10.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDiskEncryptionWindows10/MSFT_IntuneDiskEncryptionWindows10.psm1 index 5a3308a7f8..d7afdbf4d5 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDiskEncryptionWindows10/MSFT_IntuneDiskEncryptionWindows10.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDiskEncryptionWindows10/MSFT_IntuneDiskEncryptionWindows10.psm1 @@ -352,32 +352,44 @@ function Get-TargetResource Add-M365DSCTelemetryEvent -Data $data #endregion - $nullResult = $PSBoundParameters - $nullResult.Ensure = 'Absent' - $templateReferenceId = '46ddfc50-d10f-4867-b852-9434254b3bff_1' - $getValue = $null - #region resource generator code - $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Id -ErrorAction SilentlyContinue - if ($null -eq $getValue) + if ($PSBoundParameters.ContainsKey('Id')) { - Write-Verbose -Message "Could not find an Intune Disk Encryption for Windows10 with Id {$Id}" - - if (-not [System.String]::IsNullOrEmpty($DisplayName)) + Write-Verbose -Message 'PolicyID was specified' + try + { + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Id -ErrorAction Stop + } + catch { - $getValue = Get-MgBetaDeviceManagementConfigurationPolicy ` - -All ` - -Filter "Name eq '$DisplayName' and templateReference/TemplateId eq '$templateReferenceId'" ` - -ErrorAction SilentlyContinue + Write-Verbose -Message "Couldn't find existing policy by ID {$Id}" + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName' and templateReference/TemplateId eq '$templateReferenceId'" + if ($getValue.Length -gt 1) + { + throw "Duplicate Intune Disk Encryption for Windows10 named $DisplayName exist in tenant" + } } } - #endregion - if ($null -eq $getValue) + else { - Write-Verbose -Message "Could not find an Intune Disk Encryption for Windows10 with Name {$DisplayName}." - return $nullResult + Write-Verbose -Message 'Id was NOT specified' + ## Can retreive multiple Intune Policies since displayname is not unique + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName' and templateReference/TemplateId eq '$templateReferenceId'" + if ($getValue.Length -gt 1) + { + throw "Duplicate Intune Disk Encryption for Windows10 named $DisplayName exist in tenant" + } } + + if ([String]::IsNullOrEmpty($getValue.id)) + { + Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + $currentValues = $PSBoundParameters + $currentValues.Ensure = 'Absent' + return $currentValues + } + $Id = $getValue.Id Write-Verbose -Message "An Intune Disk Encryption for Windows10 with Id {$Id} and Name {$DisplayName} was found" diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyLinux/MSFT_IntuneEndpointDetectionAndResponsePolicyLinux.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyLinux/MSFT_IntuneEndpointDetectionAndResponsePolicyLinux.psm1 index 9a7af96373..d0e556f5f3 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyLinux/MSFT_IntuneEndpointDetectionAndResponsePolicyLinux.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyLinux/MSFT_IntuneEndpointDetectionAndResponsePolicyLinux.psm1 @@ -86,31 +86,42 @@ function Get-TargetResource Add-M365DSCTelemetryEvent -Data $data #endregion - $nullResult = $PSBoundParameters - $nullResult.Ensure = 'Absent' - - $getValue = $null - #region resource generator code - $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Id -ErrorAction SilentlyContinue - - if ($null -eq $getValue) + if ($PSBoundParameters.ContainsKey('Id')) { - Write-Verbose -Message "Could not find an Intune Endpoint Detection And Response Policy Linux with Id {$Id}" - - if (-not [System.String]::IsNullOrEmpty($DisplayName)) + Write-Verbose -Message 'PolicyID was specified' + try + { + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Id -ErrorAction Stop + } + catch + { + Write-Verbose -Message "Couldn't find existing policy by ID {$Id}" + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" + if ($getValue.Length -gt 1) + { + throw "Duplicate Intune Endpoint Detection And Response Policy Linux named $DisplayName exist in tenant" + } + } + } + else + { + Write-Verbose -Message 'Id was NOT specified' + ## Can retreive multiple Intune Policies since displayname is not unique + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" + if ($getValue.Length -gt 1) { - $getValue = Get-MgBetaDeviceManagementConfigurationPolicy ` - -All ` - -Filter "Name eq '$DisplayName'" ` - -ErrorAction SilentlyContinue + throw "Duplicate Intune Endpoint Detection And Response Policy Linux named $DisplayName exist in tenant" } } - #endregion - if ($null -eq $getValue) + + if ([String]::IsNullOrEmpty($getValue.id)) { - Write-Verbose -Message "Could not find an Intune Endpoint Detection And Response Policy Linux with Name {$DisplayName}." - return $nullResult + Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + $currentValues = $PSBoundParameters + $currentValues.Ensure = 'Absent' + return $currentValues } + $Id = $getValue.Id Write-Verbose -Message "An Intune Endpoint Detection And Response Policy Linux with Id {$Id} and Name {$DisplayName} was found" diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS/MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS/MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS.psm1 index 96d87c2a83..9fc519745d 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS/MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS/MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS.psm1 @@ -86,31 +86,42 @@ function Get-TargetResource Add-M365DSCTelemetryEvent -Data $data #endregion - $nullResult = $PSBoundParameters - $nullResult.Ensure = 'Absent' - - $getValue = $null - #region resource generator code - $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Id -ErrorAction SilentlyContinue - - if ($null -eq $getValue) + if ($PSBoundParameters.ContainsKey('Id')) { - Write-Verbose -Message "Could not find an Intune Endpoint Detection And Response Policy MacOS with Id {$Id}" - - if (-not [System.String]::IsNullOrEmpty($DisplayName)) + Write-Verbose -Message 'PolicyID was specified' + try + { + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Id -ErrorAction Stop + } + catch + { + Write-Verbose -Message "Couldn't find existing policy by ID {$Id}" + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" + if ($getValue.Length -gt 1) + { + throw "Duplicate Intune Endpoint Detection And Response Policy MacOS named $DisplayName exist in tenant" + } + } + } + else + { + Write-Verbose -Message 'Id was NOT specified' + ## Can retreive multiple CA Policies since displayname is not unique + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" + if ($getValue.Length -gt 1) { - $getValue = Get-MgBetaDeviceManagementConfigurationPolicy ` - -All ` - -Filter "Name eq '$DisplayName'" ` - -ErrorAction SilentlyContinue + throw "Duplicate Intune Endpoint Detection And Response Policy MacOS named $DisplayName exist in tenant" } } - #endregion - if ($null -eq $getValue) + + if ([String]::IsNullOrEmpty($getValue.id)) { - Write-Verbose -Message "Could not find an Intune Endpoint Detection And Response Policy MacOS with Name {$DisplayName}." - return $nullResult + Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + $currentValues = $PSBoundParameters + $currentValues.Ensure = 'Absent' + return $currentValues } + $Id = $getValue.Id Write-Verbose -Message "An Intune Endpoint Detection And Response Policy MacOS with Id {$Id} and Name {$DisplayName} was found" diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10/MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10/MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10.psm1 index f4dde4c6ff..e739e1b5ec 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10/MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10/MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10.psm1 @@ -90,32 +90,45 @@ function Get-TargetResource Add-M365DSCTelemetryEvent -Data $data #endregion - $nullResult = $PSBoundParameters - $nullResult.Ensure = 'Absent' - try { #Retrieve policy general settings - $policy = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Identity -ErrorAction SilentlyContinue - - if ($null -eq $policy) + if ($PSBoundParameters.ContainsKey('Identity')) { - Write-Verbose -Message "Could not find an Intune Endpoint Detection And Response Policy for Windows10 with Id {$Identity}" - - if (-not [System.String]::IsNullOrEmpty($DisplayName)) + Write-Verbose -Message 'PolicyID was specified' + try { - $policy = Get-MgBetaDeviceManagementConfigurationPolicy ` - -All ` - -Filter "Name eq '$DisplayName'" ` - -ErrorAction SilentlyContinue + $policy = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Identity -ErrorAction Stop + } + catch + { + Write-Verbose -Message "Couldn't find existing policy by ID {$Identity}" + $policy = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" + if ($policy.Length -gt 1) + { + throw "Duplicate Intune Endpoint Detection And Response Policy MacOS named $DisplayName exist in tenant" + } + } + } + else + { + Write-Verbose -Message 'Id was NOT specified' + ## Can retreive multiple Intune Policies since displayname is not unique + $policy = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" + if ($policy.Length -gt 1) + { + throw "Duplicate Intune Endpoint Detection And Response Policy for Windows10 named $DisplayName exist in tenant" } } - if ($null -eq $policy) + if ([String]::IsNullOrEmpty($policy.id)) { - Write-Verbose -Message "Could not find an Intune Endpoint Detection And Response Policy for Windows10 with Name {$DisplayName}." - return $nullResult + Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + $currentValues = $PSBoundParameters + $currentValues.Ensure = 'Absent' + return $currentValues } + $Identity = $policy.Id Write-Verbose -Message "An Intune Endpoint Detection And Response Policy for Windows10 with Id {$Identity} and Name {$DisplayName} was found" diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneFirewallPolicyWindows10/MSFT_IntuneFirewallPolicyWindows10.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneFirewallPolicyWindows10/MSFT_IntuneFirewallPolicyWindows10.psm1 index b8bf713da7..5d18804753 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneFirewallPolicyWindows10/MSFT_IntuneFirewallPolicyWindows10.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneFirewallPolicyWindows10/MSFT_IntuneFirewallPolicyWindows10.psm1 @@ -462,31 +462,42 @@ function Get-TargetResource Add-M365DSCTelemetryEvent -Data $data #endregion - $nullResult = $PSBoundParameters - $nullResult.Ensure = 'Absent' - - $getValue = $null - #region resource generator code - $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Id -ErrorAction SilentlyContinue - - if ($null -eq $getValue) + if ($PSBoundParameters.ContainsKey('Id')) { - Write-Verbose -Message "Could not find an Intune Firewall Policy for Windows10 with Id {$Id}" - - if (-not [System.String]::IsNullOrEmpty($DisplayName)) + Write-Verbose -Message 'PolicyID was specified' + try + { + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Id -ErrorAction Stop + } + catch + { + Write-Verbose -Message "Couldn't find existing policy by ID {$Id}" + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" + if ($getValue.Length -gt 1) + { + throw "Duplicate Intune Firewall Policy for Windows10 named $DisplayName exist in tenant" + } + } + } + else + { + Write-Verbose -Message 'Id was NOT specified' + ## Can retreive multiple Intune Policies since displayname is not unique + $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" + if ($getValue.Length -gt 1) { - $getValue = Get-MgBetaDeviceManagementConfigurationPolicy ` - -All ` - -Filter "Name eq '$DisplayName'" ` - -ErrorAction SilentlyContinue + throw "Duplicate Intune Firewall Policy for Windows10 named $DisplayName exist in tenant" } } - #endregion - if ($null -eq $getValue) + + if ([String]::IsNullOrEmpty($getValue.id)) { - Write-Verbose -Message "Could not find an Intune Firewall Policy for Windows10 with Name {$DisplayName}." - return $nullResult + Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + $currentValues = $PSBoundParameters + $currentValues.Ensure = 'Absent' + return $currentValues } + $Id = $getValue.Id Write-Verbose -Message "An Intune Firewall Policy for Windows10 with Id {$Id} and Name {$DisplayName} was found" diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSettingCatalogASRRulesPolicyWindows10/MSFT_IntuneSettingCatalogASRRulesPolicyWindows10.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSettingCatalogASRRulesPolicyWindows10/MSFT_IntuneSettingCatalogASRRulesPolicyWindows10.psm1 index 10f78935d9..cd05b649f0 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSettingCatalogASRRulesPolicyWindows10/MSFT_IntuneSettingCatalogASRRulesPolicyWindows10.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSettingCatalogASRRulesPolicyWindows10/MSFT_IntuneSettingCatalogASRRulesPolicyWindows10.psm1 @@ -258,35 +258,46 @@ function Get-TargetResource Add-M365DSCTelemetryEvent -Data $data #endregion - $nullResult = $PSBoundParameters - $nullResult.Ensure = 'Absent' - $templateReferenceId = 'e8c053d6-9f95-42b1-a7f1-ebfd71c67a4b_1' - #Retrieve policy general settings - $policy = $null - $policy = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Identity -ErrorAction SilentlyContinue - - if ($null -eq $policy) + if ($PSBoundParameters.ContainsKey('Identity')) { - Write-Verbose -Message "No Endpoint Protection Attack Surface Reduction Rules Policy {$Identity} was found" - - if (-not [System.String]::IsNullOrEmpty($DisplayName)) + Write-Verbose -Message 'PolicyID was specified' + try { - $policy = Get-MgBetaDeviceManagementConfigurationPolicy ` - -All ` - -Filter "Name eq '$DisplayName' and templateReference/TemplateId eq '$templateReferenceId'" ` - -ErrorAction SilentlyContinue + $policy = Get-MgBetaDeviceManagementConfigurationPolicy -DeviceManagementConfigurationPolicyId $Identity -ErrorAction Stop + } + catch + { + Write-Verbose -Message "Couldn't find existing policy by ID {$Identity}" + $policy = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName' and templateReference/TemplateId eq '$templateReferenceId'" + if ($policy.Length -gt 1) + { + throw "Duplicate Endpoint Protection Attack Surface Reduction Rules Policy named $DisplayName exist in tenant" + } + } + } + else + { + Write-Verbose -Message 'Id was NOT specified' + ## Can retreive multiple CA Policies since displayname is not unique + $policy = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName' and templateReference/TemplateId eq '$templateReferenceId'" + if ($policy.Length -gt 1) + { + throw "Duplicate Endpoint Protection Attack Surface Reduction Rules Policy named $DisplayName exist in tenant" } } - if ($null -eq $policy) + if ([String]::IsNullOrEmpty($policy.id)) { - Write-Verbose -Message "No Endpoint Protection Attack Surface Reduction Rules Policy {$DisplayName} was found" - return $nullResult + Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + $currentValues = $PSBoundParameters + $currentValues.Ensure = 'Absent' + return $currentValues } + $Identity = $policy.Id - Write-Verbose -Message "Found Endpoint Protection Attack Surface Reduction Rules Policy with Id {$Identity} and Name {$DisplayName)}." + Write-Verbose -Message "An Endpoint Protection Attack Surface Reduction Rules Policy with Id {$Identity} and Name {$DisplayName} was found" #Retrieve policy specific settings [array]$settings = Get-MgBetaDeviceManagementConfigurationPolicySetting ` From e9b867ee2952845623a8e52cccd8598ab35a0195 Mon Sep 17 00:00:00 2001 From: Alfred Schreuder Date: Wed, 11 Dec 2024 16:06:18 +0100 Subject: [PATCH 2/9] Fix dynamic group compliance check & added DOCS --- CHANGELOG.md | 29 +++++++++++++++++++ .../MSFT_AADGroup/MSFT_AADGroup.psm1 | 9 +++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca5bb76ad6..ca838b9c5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,38 @@ # UNRELEASED +* AADGroup + * Only get Members & GroupAsMembers when a static group is defined. +* IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy + * Fixed creation of policy while it was found by name, now it updates existing policies correctly. +* IntuneAccountProtectionPolicyWindows10 + * Fixed creation of policy while it was found by name, now it updates existing policies correctly. +* IntuneAntivirusPolicyLinux + * Fixed creation of policy while it was found by name, now it updates existing policies correctly. +* IntuneAntivirusPolicyMacOS + * Fixed creation of policy while it was found by name, now it updates existing policies correctly. +* IntuneAntivirusPolicyWindows10SettingCatalog + * Fixed creation of policy while it was found by name, now it updates existing policies correctly. +* IntuneAppAndBrowserIsolationPolicyWindows10 + * Fixed creation of policy while it was found by name, now it updates existing policies correctly. +* IntuneDeviceControlPolicyWindows10 + * Fixed creation of policy while it was found by name, now it updates existing policies correctly. +* IntuneDiskEncryptionMacOS + * Fixed creation of policy while it was found by name, now it updates existing policies correctly. +* IntuneDiskEncryptionWindows10 + * Fixed creation of policy while it was found by name, now it updates existing policies correctly. +* IntuneEndpointDetectionAndResponsePolicyLinux + * Fixed creation of policy while it was found by name, now it updates existing policies correctly. +* IntuneEndpointDetectionAndResponsePolicyMacOS + * Fixed creation of policy while it was found by name, now it updates existing policies correctly. +* IntuneEndpointDetectionAndResponsePolicyWindows10 + * Fixed creation of policy while it was found by name, now it updates existing policies correctly. +* IntuneSettingCatalogASRRulesPolicyWindows10 + * Fixed creation of policy while it was found by name, now it updates existing policies correctly. * IntuneDeviceManagementAndroidDeviceOwnerEnrollmentProfile * Fixing issue with the way the QrCodeImage property was exported and handled. * IntuneFirewallPolicyWindows10 + * Fixed creation of policy while it was found by name, now it updates existing policies correctly. * Fix export of properties that appear multiple times in subsections. # 1.24.1204.1 diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADGroup/MSFT_AADGroup.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADGroup/MSFT_AADGroup.psm1 index 538b67f9f6..66474ddeba 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADGroup/MSFT_AADGroup.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADGroup/MSFT_AADGroup.psm1 @@ -216,6 +216,7 @@ function Get-TargetResource } $MembersValues = $null + $result = @{} if ($Group.MembershipRuleProcessingState -ne 'On') { # Members @@ -237,6 +238,8 @@ function Get-TargetResource $GroupAsMembersValues += $member.AdditionalProperties.displayName } } + $result.Add('Members', $MembersValues) + $result.Add('GroupAsMembers', $GroupAsMembersValues) } # MemberOf @@ -273,15 +276,12 @@ function Get-TargetResource if ($assignedLicensesRequest.value.Length -gt 0) { $assignedLicensesValues = Get-M365DSCAzureADGroupLicenses -AssignedLicenses $assignedLicensesRequest.value - } - $result = @{ + $policySettings = @{ DisplayName = $Group.DisplayName Id = $Group.Id Owners = $OwnersValues - Members = $MembersValues - GroupAsMembers = $GroupAsMembersValues MemberOf = $MemberOfValues Description = $Group.Description GroupTypes = [System.String[]]$Group.GroupTypes @@ -303,6 +303,7 @@ function Get-TargetResource Managedidentity = $ManagedIdentity.IsPresent AccessTokens = $AccessTokens } + $result += $policySettings return $result } From 67dd4bb0f1dab649460d49d2045dca8e036d005d Mon Sep 17 00:00:00 2001 From: "Alfred (F.) Schreuder" Date: Wed, 11 Dec 2024 22:51:57 +0100 Subject: [PATCH 3/9] Update Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.psm1 Typo Co-authored-by: Fabien Tschanz <71251572+FabienTschanz@users.noreply.github.com> --- ...countProtectionLocalAdministratorPasswordSolutionPolicy.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.psm1 index fe51e6dbd5..867a2000dd 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.psm1 @@ -145,7 +145,7 @@ function Get-TargetResource $policy = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName' and templateReference/TemplateId eq '$templateReferenceId'" if ($policy.Length -gt 1) { - throw "Duplicate Account Protection LAPS Policyy named $DisplayName exist in tenant" + throw "Duplicate Account Protection LAPS Policy named $DisplayName exist in tenant" } } } From d21970e324e4741f11e90a31b96a3b62118b7aac Mon Sep 17 00:00:00 2001 From: "Alfred (F.) Schreuder" Date: Wed, 11 Dec 2024 23:16:39 +0100 Subject: [PATCH 4/9] Update MSFT_IntuneSettingCatalogASRRulesPolicyWindows10.psm1 Capital I --- .../MSFT_IntuneSettingCatalogASRRulesPolicyWindows10.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSettingCatalogASRRulesPolicyWindows10/MSFT_IntuneSettingCatalogASRRulesPolicyWindows10.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSettingCatalogASRRulesPolicyWindows10/MSFT_IntuneSettingCatalogASRRulesPolicyWindows10.psm1 index cd05b649f0..9f2091d666 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSettingCatalogASRRulesPolicyWindows10/MSFT_IntuneSettingCatalogASRRulesPolicyWindows10.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSettingCatalogASRRulesPolicyWindows10/MSFT_IntuneSettingCatalogASRRulesPolicyWindows10.psm1 @@ -288,7 +288,7 @@ function Get-TargetResource } } - if ([String]::IsNullOrEmpty($policy.id)) + if ([String]::IsNullOrEmpty($policy.Id)) { Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" $currentValues = $PSBoundParameters From e91cf869c06ec7ee2306492901ea9eed98134d55 Mon Sep 17 00:00:00 2001 From: "Alfred (F.) Schreuder" Date: Wed, 11 Dec 2024 23:18:56 +0100 Subject: [PATCH 5/9] Update MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.psm1 Capital I --- ...countProtectionLocalAdministratorPasswordSolutionPolicy.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.psm1 index 867a2000dd..b502224361 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.psm1 @@ -160,7 +160,7 @@ function Get-TargetResource } } - if ([String]::IsNullOrEmpty($policy.id)) + if ([String]::IsNullOrEmpty($policy.Id)) { Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" $currentValues = $PSBoundParameters From 075a18837c3a453f507b6accbe9c4eaab90d4372 Mon Sep 17 00:00:00 2001 From: "Alfred (F.) Schreuder" Date: Wed, 11 Dec 2024 23:20:50 +0100 Subject: [PATCH 6/9] Update MSFT_IntuneAccountProtectionPolicyWindows10.psm1 Capital I --- .../MSFT_IntuneAccountProtectionPolicyWindows10.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionPolicyWindows10/MSFT_IntuneAccountProtectionPolicyWindows10.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionPolicyWindows10/MSFT_IntuneAccountProtectionPolicyWindows10.psm1 index 9360029c10..7348ec7331 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionPolicyWindows10/MSFT_IntuneAccountProtectionPolicyWindows10.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionPolicyWindows10/MSFT_IntuneAccountProtectionPolicyWindows10.psm1 @@ -113,7 +113,7 @@ function Get-TargetResource } } - if ([String]::IsNullOrEmpty($getValue.id)) + if ([String]::IsNullOrEmpty($getValue.Id)) { Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" $currentValues = $PSBoundParameters From 8cfff9326e5af34f296cbb9624d0b7787324fd81 Mon Sep 17 00:00:00 2001 From: "Alfred (F.) Schreuder" Date: Wed, 11 Dec 2024 23:21:26 +0100 Subject: [PATCH 7/9] Update MSFT_IntuneAntivirusPolicyLinux.psm1 Capital I --- .../MSFT_IntuneAntivirusPolicyLinux.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyLinux/MSFT_IntuneAntivirusPolicyLinux.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyLinux/MSFT_IntuneAntivirusPolicyLinux.psm1 index d5bf54a020..ca3a28724c 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyLinux/MSFT_IntuneAntivirusPolicyLinux.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyLinux/MSFT_IntuneAntivirusPolicyLinux.psm1 @@ -220,7 +220,7 @@ function Get-TargetResource } } - if ([String]::IsNullOrEmpty($getValue.id)) + if ([String]::IsNullOrEmpty($getValue.Id)) { Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" $currentValues = $PSBoundParameters From 6d8a9be302f3b5e0839148f9a7a8c253d88d4cc7 Mon Sep 17 00:00:00 2001 From: Alfred Schreuder Date: Wed, 11 Dec 2024 23:31:15 +0100 Subject: [PATCH 8/9] Capital I --- .../MSFT_IntuneAntivirusPolicyMacOS.psm1 | 2 +- .../MSFT_IntuneAppAndBrowserIsolationPolicyWindows10.psm1 | 2 +- .../MSFT_IntuneDeviceControlPolicyWindows10.psm1 | 2 +- .../MSFT_IntuneDiskEncryptionMacOS.psm1 | 2 +- .../MSFT_IntuneDiskEncryptionWindows10.psm1 | 2 +- .../MSFT_IntuneEndpointDetectionAndResponsePolicyLinux.psm1 | 2 +- .../MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS.psm1 | 2 +- .../MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10.psm1 | 2 +- .../MSFT_IntuneFirewallPolicyWindows10.psm1 | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyMacOS/MSFT_IntuneAntivirusPolicyMacOS.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyMacOS/MSFT_IntuneAntivirusPolicyMacOS.psm1 index a844a3c8bb..37c4fe74e0 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyMacOS/MSFT_IntuneAntivirusPolicyMacOS.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyMacOS/MSFT_IntuneAntivirusPolicyMacOS.psm1 @@ -223,7 +223,7 @@ function Get-TargetResource } } - if ([String]::IsNullOrEmpty($getValue.id)) + if ([String]::IsNullOrEmpty($getValue.Id)) { Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" $currentValues = $PSBoundParameters diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAppAndBrowserIsolationPolicyWindows10/MSFT_IntuneAppAndBrowserIsolationPolicyWindows10.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAppAndBrowserIsolationPolicyWindows10/MSFT_IntuneAppAndBrowserIsolationPolicyWindows10.psm1 index 8d8be2e444..879ed4eddb 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAppAndBrowserIsolationPolicyWindows10/MSFT_IntuneAppAndBrowserIsolationPolicyWindows10.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAppAndBrowserIsolationPolicyWindows10/MSFT_IntuneAppAndBrowserIsolationPolicyWindows10.psm1 @@ -193,7 +193,7 @@ function Get-TargetResource } } - if ([String]::IsNullOrEmpty($getValue.id)) + if ([String]::IsNullOrEmpty($getValue.Id)) { Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" $currentValues = $PSBoundParameters diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDeviceControlPolicyWindows10/MSFT_IntuneDeviceControlPolicyWindows10.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDeviceControlPolicyWindows10/MSFT_IntuneDeviceControlPolicyWindows10.psm1 index 0d8094acd2..1d84df411d 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDeviceControlPolicyWindows10/MSFT_IntuneDeviceControlPolicyWindows10.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDeviceControlPolicyWindows10/MSFT_IntuneDeviceControlPolicyWindows10.psm1 @@ -279,7 +279,7 @@ function Get-TargetResource } } - if ([String]::IsNullOrEmpty($getValue.id)) + if ([String]::IsNullOrEmpty($getValue.Id)) { Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" $currentValues = $PSBoundParameters diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDiskEncryptionMacOS/MSFT_IntuneDiskEncryptionMacOS.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDiskEncryptionMacOS/MSFT_IntuneDiskEncryptionMacOS.psm1 index bf084c61ac..c8a5b0c711 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDiskEncryptionMacOS/MSFT_IntuneDiskEncryptionMacOS.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDiskEncryptionMacOS/MSFT_IntuneDiskEncryptionMacOS.psm1 @@ -140,7 +140,7 @@ function Get-TargetResource } } - if ([String]::IsNullOrEmpty($getValue.id)) + if ([String]::IsNullOrEmpty($getValue.Id)) { Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" $currentValues = $PSBoundParameters diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDiskEncryptionWindows10/MSFT_IntuneDiskEncryptionWindows10.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDiskEncryptionWindows10/MSFT_IntuneDiskEncryptionWindows10.psm1 index d7afdbf4d5..4d336db72a 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDiskEncryptionWindows10/MSFT_IntuneDiskEncryptionWindows10.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDiskEncryptionWindows10/MSFT_IntuneDiskEncryptionWindows10.psm1 @@ -382,7 +382,7 @@ function Get-TargetResource } } - if ([String]::IsNullOrEmpty($getValue.id)) + if ([String]::IsNullOrEmpty($getValue.Id)) { Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" $currentValues = $PSBoundParameters diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyLinux/MSFT_IntuneEndpointDetectionAndResponsePolicyLinux.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyLinux/MSFT_IntuneEndpointDetectionAndResponsePolicyLinux.psm1 index d0e556f5f3..f01965c904 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyLinux/MSFT_IntuneEndpointDetectionAndResponsePolicyLinux.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyLinux/MSFT_IntuneEndpointDetectionAndResponsePolicyLinux.psm1 @@ -114,7 +114,7 @@ function Get-TargetResource } } - if ([String]::IsNullOrEmpty($getValue.id)) + if ([String]::IsNullOrEmpty($getValue.Id)) { Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" $currentValues = $PSBoundParameters diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS/MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS/MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS.psm1 index 9fc519745d..77b7bb28b5 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS/MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS/MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS.psm1 @@ -114,7 +114,7 @@ function Get-TargetResource } } - if ([String]::IsNullOrEmpty($getValue.id)) + if ([String]::IsNullOrEmpty($getValue.Id)) { Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" $currentValues = $PSBoundParameters diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10/MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10/MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10.psm1 index e739e1b5ec..9096e5073c 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10/MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10/MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10.psm1 @@ -121,7 +121,7 @@ function Get-TargetResource } } - if ([String]::IsNullOrEmpty($policy.id)) + if ([String]::IsNullOrEmpty($policy.Id)) { Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" $currentValues = $PSBoundParameters diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneFirewallPolicyWindows10/MSFT_IntuneFirewallPolicyWindows10.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneFirewallPolicyWindows10/MSFT_IntuneFirewallPolicyWindows10.psm1 index 5d18804753..86069f2b2a 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneFirewallPolicyWindows10/MSFT_IntuneFirewallPolicyWindows10.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneFirewallPolicyWindows10/MSFT_IntuneFirewallPolicyWindows10.psm1 @@ -490,7 +490,7 @@ function Get-TargetResource } } - if ([String]::IsNullOrEmpty($getValue.id)) + if ([String]::IsNullOrEmpty($getValue.Id)) { Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" $currentValues = $PSBoundParameters From d2649e5cf2175fc6b8d12ed0f2ddd7bd4e83a6a1 Mon Sep 17 00:00:00 2001 From: Alfred Schreuder Date: Thu, 12 Dec 2024 10:24:38 +0100 Subject: [PATCH 9/9] Update verbose messages --- ...untProtectionLocalAdministratorPasswordSolutionPolicy.psm1 | 4 ++-- .../MSFT_IntuneAccountProtectionPolicyWindows10.psm1 | 4 ++-- .../MSFT_IntuneAntivirusPolicyLinux.psm1 | 4 ++-- .../MSFT_IntuneAntivirusPolicyMacOS.psm1 | 4 ++-- .../MSFT_IntuneAntivirusPolicyWindows10SettingCatalog.psm1 | 4 ++-- .../MSFT_IntuneAppAndBrowserIsolationPolicyWindows10.psm1 | 4 ++-- .../MSFT_IntuneDeviceControlPolicyWindows10.psm1 | 4 ++-- .../MSFT_IntuneDiskEncryptionMacOS.psm1 | 4 ++-- .../MSFT_IntuneDiskEncryptionWindows10.psm1 | 4 ++-- .../MSFT_IntuneEndpointDetectionAndResponsePolicyLinux.psm1 | 4 ++-- .../MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS.psm1 | 4 ++-- ...SFT_IntuneEndpointDetectionAndResponsePolicyWindows10.psm1 | 4 ++-- .../MSFT_IntuneFirewallPolicyWindows10.psm1 | 4 ++-- .../MSFT_IntuneSettingCatalogASRRulesPolicyWindows10.psm1 | 4 ++-- 14 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.psm1 index b502224361..3410033562 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy/MSFT_IntuneAccountProtectionLocalAdministratorPasswordSolutionPolicy.psm1 @@ -141,7 +141,7 @@ function Get-TargetResource } catch { - Write-Verbose -Message "Couldn't find existing policy by ID {$Identity}" + Write-Verbose -Message "No Account Protection LAPS Policy with Id {$Identity} was found" $policy = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName' and templateReference/TemplateId eq '$templateReferenceId'" if ($policy.Length -gt 1) { @@ -162,7 +162,7 @@ function Get-TargetResource if ([String]::IsNullOrEmpty($policy.Id)) { - Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + Write-Verbose -Message "No Account Protection LAPS Policy with Name {$DisplayName} were found" $currentValues = $PSBoundParameters $currentValues.Ensure = 'Absent' return $currentValues diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionPolicyWindows10/MSFT_IntuneAccountProtectionPolicyWindows10.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionPolicyWindows10/MSFT_IntuneAccountProtectionPolicyWindows10.psm1 index 7348ec7331..62ba4b3e06 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionPolicyWindows10/MSFT_IntuneAccountProtectionPolicyWindows10.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAccountProtectionPolicyWindows10/MSFT_IntuneAccountProtectionPolicyWindows10.psm1 @@ -94,7 +94,7 @@ function Get-TargetResource } catch { - Write-Verbose -Message "Couldn't find existing policy by ID {$Id}" + Write-Verbose -Message "No Account Protection Policy for Windows10 with Id {$Id} was found" $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" if ($getValue.Length -gt 1) { @@ -115,7 +115,7 @@ function Get-TargetResource if ([String]::IsNullOrEmpty($getValue.Id)) { - Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + Write-Verbose -Message "No Account Protection Policy for Windows10 with Name {$DisplayName} were found" $currentValues = $PSBoundParameters $currentValues.Ensure = 'Absent' return $currentValues diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyLinux/MSFT_IntuneAntivirusPolicyLinux.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyLinux/MSFT_IntuneAntivirusPolicyLinux.psm1 index ca3a28724c..05b2f19f2a 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyLinux/MSFT_IntuneAntivirusPolicyLinux.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyLinux/MSFT_IntuneAntivirusPolicyLinux.psm1 @@ -201,7 +201,7 @@ function Get-TargetResource } catch { - Write-Verbose -Message "Couldn't find existing policy by ID {$Id}" + Write-Verbose -Message "No Intune Antivirus Policy for Linux with Id {$Id} was found" $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" if ($getValue.Length -gt 1) { @@ -222,7 +222,7 @@ function Get-TargetResource if ([String]::IsNullOrEmpty($getValue.Id)) { - Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + Write-Verbose -Message "No Intune Antivirus Policy for Linux with Name {$DisplayName} were found" $currentValues = $PSBoundParameters $currentValues.Ensure = 'Absent' return $currentValues diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyMacOS/MSFT_IntuneAntivirusPolicyMacOS.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyMacOS/MSFT_IntuneAntivirusPolicyMacOS.psm1 index 37c4fe74e0..3898ab51c6 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyMacOS/MSFT_IntuneAntivirusPolicyMacOS.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyMacOS/MSFT_IntuneAntivirusPolicyMacOS.psm1 @@ -204,7 +204,7 @@ function Get-TargetResource } catch { - Write-Verbose -Message "Couldn't find existing policy by ID {$Id}" + Write-Verbose -Message "No Intune Antivirus Policy for macOS with Id {$Id} was found" $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" if ($getValue.Length -gt 1) { @@ -225,7 +225,7 @@ function Get-TargetResource if ([String]::IsNullOrEmpty($getValue.Id)) { - Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + Write-Verbose -Message "No Intune Antivirus Policy for macOS with Name {$DisplayName} were found" $currentValues = $PSBoundParameters $currentValues.Ensure = 'Absent' return $currentValues diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyWindows10SettingCatalog/MSFT_IntuneAntivirusPolicyWindows10SettingCatalog.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyWindows10SettingCatalog/MSFT_IntuneAntivirusPolicyWindows10SettingCatalog.psm1 index 79ce7692b0..0b437edb5e 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyWindows10SettingCatalog/MSFT_IntuneAntivirusPolicyWindows10SettingCatalog.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAntivirusPolicyWindows10SettingCatalog/MSFT_IntuneAntivirusPolicyWindows10SettingCatalog.psm1 @@ -450,7 +450,7 @@ function Get-TargetResource } catch { - Write-Verbose -Message "Couldn't find existing policy by ID {$Identity}" + Write-Verbose -Message "No Intune Antivirus Policy for Windows10 Setting Catalog with Id {$Identity} was found" $policy = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" | Where-Object -FilterScript {$_.TemplateReference.TemplateId -in $templateReferences} if ($policy.Length -gt 1) { @@ -471,7 +471,7 @@ function Get-TargetResource if ([String]::IsNullOrEmpty($policy.Id)) { - Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + Write-Verbose -Message "No Intune Antivirus Policy for Windows10 Setting Catalog with Name {$DisplayName} were found" $currentValues = $PSBoundParameters $currentValues.Ensure = 'Absent' return $currentValues diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAppAndBrowserIsolationPolicyWindows10/MSFT_IntuneAppAndBrowserIsolationPolicyWindows10.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAppAndBrowserIsolationPolicyWindows10/MSFT_IntuneAppAndBrowserIsolationPolicyWindows10.psm1 index 879ed4eddb..fe61754bb4 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAppAndBrowserIsolationPolicyWindows10/MSFT_IntuneAppAndBrowserIsolationPolicyWindows10.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneAppAndBrowserIsolationPolicyWindows10/MSFT_IntuneAppAndBrowserIsolationPolicyWindows10.psm1 @@ -174,7 +174,7 @@ function Get-TargetResource } catch { - Write-Verbose -Message "Couldn't find existing policy by ID {$Id}" + Write-Verbose -Message "No Intune App And Browser Isolation Policy for Windows10 with Id {$Id} was found" $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" if ($getValue.Length -gt 1) { @@ -195,7 +195,7 @@ function Get-TargetResource if ([String]::IsNullOrEmpty($getValue.Id)) { - Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + Write-Verbose -Message "No Intune App And Browser Isolation Policy for Windows10 with Name {$DisplayName} were found" $currentValues = $PSBoundParameters $currentValues.Ensure = 'Absent' return $currentValues diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDeviceControlPolicyWindows10/MSFT_IntuneDeviceControlPolicyWindows10.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDeviceControlPolicyWindows10/MSFT_IntuneDeviceControlPolicyWindows10.psm1 index 1d84df411d..badc01c989 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDeviceControlPolicyWindows10/MSFT_IntuneDeviceControlPolicyWindows10.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDeviceControlPolicyWindows10/MSFT_IntuneDeviceControlPolicyWindows10.psm1 @@ -260,7 +260,7 @@ function Get-TargetResource } catch { - Write-Verbose -Message "Couldn't find existing policy by ID {$Id}" + Write-Verbose -Message "No Intune Device Control Policy for Windows10 with Id {$Id} was found" $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" if ($getValue.Length -gt 1) { @@ -281,7 +281,7 @@ function Get-TargetResource if ([String]::IsNullOrEmpty($getValue.Id)) { - Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + Write-Verbose -Message "No Intune Device Control Policy for Windows10 with Name {$DisplayName} were found" $currentValues = $PSBoundParameters $currentValues.Ensure = 'Absent' return $currentValues diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDiskEncryptionMacOS/MSFT_IntuneDiskEncryptionMacOS.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDiskEncryptionMacOS/MSFT_IntuneDiskEncryptionMacOS.psm1 index c8a5b0c711..b7e9040f2d 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDiskEncryptionMacOS/MSFT_IntuneDiskEncryptionMacOS.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDiskEncryptionMacOS/MSFT_IntuneDiskEncryptionMacOS.psm1 @@ -121,7 +121,7 @@ function Get-TargetResource } catch { - Write-Verbose -Message "Couldn't find existing policy by ID {$Id}" + Write-Verbose -Message "No Intune Disk Encryption for macOS with Id {$Id} was found" $getValue = Get-MgBetaDeviceManagementIntent -All -Filter "DisplayName eq '$DisplayName'" | Where-Object -FilterScript {$_.TemplateId -eq 'a239407c-698d-4ef8-b314-e3ae409204b8'} if ($getValue.Length -gt 1) { @@ -142,7 +142,7 @@ function Get-TargetResource if ([String]::IsNullOrEmpty($getValue.Id)) { - Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + Write-Verbose -Message "No Intune Disk Encryption for macOS with Name {$DisplayName} were found" $currentValues = $PSBoundParameters $currentValues.Ensure = 'Absent' return $currentValues diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDiskEncryptionWindows10/MSFT_IntuneDiskEncryptionWindows10.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDiskEncryptionWindows10/MSFT_IntuneDiskEncryptionWindows10.psm1 index 4d336db72a..fbf056d14a 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDiskEncryptionWindows10/MSFT_IntuneDiskEncryptionWindows10.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneDiskEncryptionWindows10/MSFT_IntuneDiskEncryptionWindows10.psm1 @@ -363,7 +363,7 @@ function Get-TargetResource } catch { - Write-Verbose -Message "Couldn't find existing policy by ID {$Id}" + Write-Verbose -Message "No Intune Disk Encryption for Windows10 with Id {$Id} was found" $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName' and templateReference/TemplateId eq '$templateReferenceId'" if ($getValue.Length -gt 1) { @@ -384,7 +384,7 @@ function Get-TargetResource if ([String]::IsNullOrEmpty($getValue.Id)) { - Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + Write-Verbose -Message "No Intune Disk Encryption for Windows10 with Name {$DisplayName} were found" $currentValues = $PSBoundParameters $currentValues.Ensure = 'Absent' return $currentValues diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyLinux/MSFT_IntuneEndpointDetectionAndResponsePolicyLinux.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyLinux/MSFT_IntuneEndpointDetectionAndResponsePolicyLinux.psm1 index f01965c904..d7aac8dae5 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyLinux/MSFT_IntuneEndpointDetectionAndResponsePolicyLinux.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyLinux/MSFT_IntuneEndpointDetectionAndResponsePolicyLinux.psm1 @@ -95,7 +95,7 @@ function Get-TargetResource } catch { - Write-Verbose -Message "Couldn't find existing policy by ID {$Id}" + Write-Verbose -Message "No Intune Endpoint Detection And Response Policy Linux with Id {$Id} was found" $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" if ($getValue.Length -gt 1) { @@ -116,7 +116,7 @@ function Get-TargetResource if ([String]::IsNullOrEmpty($getValue.Id)) { - Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + Write-Verbose -Message "No Intune Endpoint Detection And Response Policy Linux with Name {$DisplayName} were found" $currentValues = $PSBoundParameters $currentValues.Ensure = 'Absent' return $currentValues diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS/MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS/MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS.psm1 index 77b7bb28b5..d3ebe0eef0 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS/MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS/MSFT_IntuneEndpointDetectionAndResponsePolicyMacOS.psm1 @@ -95,7 +95,7 @@ function Get-TargetResource } catch { - Write-Verbose -Message "Couldn't find existing policy by ID {$Id}" + Write-Verbose -Message "No Intune Endpoint Detection And Response Policy MacOS with Id {$Id} was found" $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" if ($getValue.Length -gt 1) { @@ -116,7 +116,7 @@ function Get-TargetResource if ([String]::IsNullOrEmpty($getValue.Id)) { - Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + Write-Verbose -Message "No Intune Endpoint Detection And Response Policy MacOS with Name {$DisplayName} were found" $currentValues = $PSBoundParameters $currentValues.Ensure = 'Absent' return $currentValues diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10/MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10/MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10.psm1 index 9096e5073c..175d7bd05f 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10/MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10/MSFT_IntuneEndpointDetectionAndResponsePolicyWindows10.psm1 @@ -102,7 +102,7 @@ function Get-TargetResource } catch { - Write-Verbose -Message "Couldn't find existing policy by ID {$Identity}" + Write-Verbose -Message "No Intune Endpoint Detection And Response Policy for Windows10 with Id {$Identity} was found" $policy = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" if ($policy.Length -gt 1) { @@ -123,7 +123,7 @@ function Get-TargetResource if ([String]::IsNullOrEmpty($policy.Id)) { - Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + Write-Verbose -Message "No Intune Endpoint Detection And Response Policy for Windows10 with Name {$DisplayName} were found" $currentValues = $PSBoundParameters $currentValues.Ensure = 'Absent' return $currentValues diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneFirewallPolicyWindows10/MSFT_IntuneFirewallPolicyWindows10.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneFirewallPolicyWindows10/MSFT_IntuneFirewallPolicyWindows10.psm1 index 86069f2b2a..bb1db762ab 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneFirewallPolicyWindows10/MSFT_IntuneFirewallPolicyWindows10.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneFirewallPolicyWindows10/MSFT_IntuneFirewallPolicyWindows10.psm1 @@ -471,7 +471,7 @@ function Get-TargetResource } catch { - Write-Verbose -Message "Couldn't find existing policy by ID {$Id}" + Write-Verbose -Message "No Intune Firewall Policy for Windows10 with Id {$Id} was found" $getValue = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName'" if ($getValue.Length -gt 1) { @@ -492,7 +492,7 @@ function Get-TargetResource if ([String]::IsNullOrEmpty($getValue.Id)) { - Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + Write-Verbose -Message "No Intune Firewall Policy for Windows10 with Name {$DisplayName} were found" $currentValues = $PSBoundParameters $currentValues.Ensure = 'Absent' return $currentValues diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSettingCatalogASRRulesPolicyWindows10/MSFT_IntuneSettingCatalogASRRulesPolicyWindows10.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSettingCatalogASRRulesPolicyWindows10/MSFT_IntuneSettingCatalogASRRulesPolicyWindows10.psm1 index 9f2091d666..3756cbe861 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSettingCatalogASRRulesPolicyWindows10/MSFT_IntuneSettingCatalogASRRulesPolicyWindows10.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_IntuneSettingCatalogASRRulesPolicyWindows10/MSFT_IntuneSettingCatalogASRRulesPolicyWindows10.psm1 @@ -269,7 +269,7 @@ function Get-TargetResource } catch { - Write-Verbose -Message "Couldn't find existing policy by ID {$Identity}" + Write-Verbose -Message "No Endpoint Protection Attack Surface Reduction Rules Policy with Id {$Identity} was found" $policy = Get-MgBetaDeviceManagementConfigurationPolicy -All -Filter "Name eq '$DisplayName' and templateReference/TemplateId eq '$templateReferenceId'" if ($policy.Length -gt 1) { @@ -290,7 +290,7 @@ function Get-TargetResource if ([String]::IsNullOrEmpty($policy.Id)) { - Write-Verbose -Message "No existing Policy with name {$DisplayName} were found" + Write-Verbose -Message "No Endpoint Protection Attack Surface Reduction Rules Policy with Name {$DisplayName} were found" $currentValues = $PSBoundParameters $currentValues.Ensure = 'Absent' return $currentValues