-
Notifications
You must be signed in to change notification settings - Fork 503
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
mutiple Configuration Erros #5441
Comments
Mode LastWriteTime Length Name -a---- 20/11/2024 23:01 2424 localhost.mof VERBOSE: [DESKTOP-9NEA30J]: LCM: [ End Set ] VERBOSE: Operation 'Invoke CimMethod' complete.
CIS compliance HTML report generated successfully.
Disconnected from Microsoft Graph. |
@asadvohra First, I would start by updating the Microsoft365DSC version to the latest version 1.24.1120.1 (released yesterday). Your version is already quite old. Secondly, there is an error message Additionally, you don't need to install all the Graph modules, simply running |
Description of the issue
Can someone please validate my script, im continiously getting errors, sometime graph authentication sometime authencation method.
Full Script to Configure CIS Compliance
Write-Host "Enabling WinRM and setting execution policy..." -ForegroundColor Cyan
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
Enable-PSRemoting -Force
Install Required Modules
Write-Host "Installing required PowerShell modules..." -ForegroundColor Cyan
Install-Module -Name Microsoft365DSC -RequiredVersion 1.24.626.1 -Force -AllowClobber
Install-Module Microsoft.Graph -Force -AllowClobber
Update Installed Modules
Write-Host "Updating installed PowerShell modules..." -ForegroundColor Cyan
#Update-Module Microsoft.Graph -force
#Update-Module Microsoft365DSC -force
Update-M365DSCDependencies -force
#Verfication of modules installing
Get-Module -ListAvailable -Name Microsoft365DSC, Microsoft.Graph,ExchangeOnlineManagement | Select Name, ModuleBase
Application and Tenant Details
$ApplicationId = "abc"
$TenantId = "123.onmicrosoft.com"
$ApplicationSecret = "123"
Convert Client Secret to SecureString
$SecureClientSecret = ConvertTo-SecureString -String $ApplicationSecret -AsPlainText -Force
$ClientSecretCredential = New-Object System.Management.Automation.PSCredential($ApplicationId, $SecureClientSecret)
Connect to Microsoft Graph
Connect-MgGraph -TenantId $TenantId -ClientSecretCredential $ClientSecretCredential
Write-Host "Connected to Microsoft Graph successfully." -ForegroundColor Green
#Authentication Verification
Write-Host "Successfully Authentic." -ForegroundColor Green
Get-MgContext
Define the Configuration
Configuration CISCompliancePolicies {
Import-DscResource -ModuleName 'Microsoft365DSC' -ModuleVersion '1.24.626.1'
}
Define Variables
$ApplicationId = "123" # Replace with your app ID
$TenantId = "123.onmicrosoft.com" # Replace with your tenant ID
$ApplicationSecret = "123" # Replace with your client secret
$SecureClientSecret = ConvertTo-SecureString -String $ApplicationSecret -AsPlainText -Force
$Credscredential = New-Object System.Management.Automation.PSCredential($ApplicationId, $SecureClientSecret)
Output Path for Configuration
$ConfigPath = "C:\CISCompliancePolicies"
CISCompliancePolicies -OutputPath $ConfigPath
Apply the Configuration
Start-DscConfiguration -Path $ConfigPath -Wait -Force -Verbose
Write-Host "CIS compliance policies configured successfully." -ForegroundColor Green
Export the Current Configuration
Write-Host "Exporting current configuration to generate HTML report..." -ForegroundColor Cyan
Export-M365DSCConfiguration
-Components @("AADGroup")
-ApplicationId $ApplicationId
-ApplicationSecret $ApplicationSecret
-TenantId $TenantId `
-ConfigurationType HTML
Write-Host "CIS compliance HTML report generated successfully." -ForegroundColor Green
Disconnect from Microsoft Graph
Disconnect-MgGraph
Write-Host "Disconnected from Microsoft Graph." -ForegroundColor Green
Microsoft 365 DSC Version
1.24.626.1
Which workloads are affected
Azure Active Directory (Entra ID), Exchange Online, Security & Compliance Center
The DSC configuration
Verbose logs showing the problem
Environment Information + PowerShell Version
The text was updated successfully, but these errors were encountered: