Så här säkerställer du att modern autentisering är aktiverad i Office 365 med PowerShell

Modern autentisering är en säkerhetsfunktion i Office 365 som använder Azure Active Directory (AAD) för att autentisera användare. Den står som en ledstjärna för säkerhet och överskuggar traditionella autentiseringsmetoder som Basic Authentication. Varför? Modern autentisering använder starkare kryptering och ett extra lager av tvåfaktorsautentisering, vilket gör den till en formidabel försvarsmekanism i dagens cyberlandskap.

Att förstå manuset

I grund och botten är skriptet utformat för att ge klarhet i statusen för modern autentisering över användarprofiler i en Office 365-miljö. Hur uppnår den detta? Genom att noggrant gå igenom varje användarprofil på maskinen och inspektera de registervärden som är kopplade till modern autentisering. Om den stöter på värdet 0 är det en tydlig indikator på att modern autentisering är inaktiverad för den specifika användarprofilen.

Manus

#Requires -Version 5.1

<#
.SYNOPSIS
    Monitors if user profiles have modern auth for Office 365 enabled or disabled.
.DESCRIPTION
    Monitors if user profiles have modern auth for Office 365 enabled or disabled.
    Check if HKEY_CURRENT_USERSOFTWAREMicrosoftOffice15.0CommonIdentityEnableADAL is set to 1.
    Check if HKEY_CURRENT_USERSOFTWAREMicrosoftOffice16.0CommonIdentityEnableADAL is set to 0.
    Returns an exit code of 1 if one user has modern auth disabled.
    Returns an exit code of 0 if all user have modern auth enabled.
.EXAMPLE
     No parameter needed.
.OUTPUTS
    None
.NOTES
    Minimum OS Architecture Supported: Windows 10, Windows Server 2016
    Release Notes:
    Initial Release
By using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https://www.ninjaone.com/terms-of-use.
    Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. 
    Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. 
    Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. 
    Warranty Disclaimer: The script is provided “as is” and “as available”, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. 
    Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. 
    Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. 
    EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).
#>

[CmdletBinding()]
param ()

begin {
    function Test-IsElevated {
        $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()
        $p = New-Object System.Security.Principal.WindowsPrincipal($id)
        $p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)
    }
}
process {
    if (-not (Test-IsElevated)) {
        Write-Error -Message "Access Denied. Please run with Administrator privileges."
        exit 1
    }
    # Loop through each user's profile
    # Check if HKEY_CURRENT_USERSOFTWAREMicrosoftOffice15.0CommonIdentityEnableADAL is set to 1
    # Check if HKEY_CURRENT_USERSOFTWAREMicrosoftOffice16.0CommonIdentityEnableADAL is set to 1

    $Path = @("SOFTWAREMicrosoftOffice15.0CommonIdentity", "SOFTWAREMicrosoftOffice16.0CommonIdentity")
    $Name = "EnableADAL"

    $Script:FoundModernAuthDisabled = $false

    # Get each user profile SID and Path to the profile
    $UserProfiles = Get-ItemProperty -Path "HKLM:SOFTWAREMicrosoftWindows NTCurrentVersionProfileList*" |
        Where-Object { $_.PSChildName -match "S-1-5-21-(d+-?){4}$" } |
        Select-Object @{Name = "SID"; Expression = { $_.PSChildName } }, @{Name = "UserHive"; Expression = { "$($_.ProfileImagePath)NTuser.dat" } }, @{Name = "UserName"; Expression = { "$($_.ProfileImagePath | Split-Path -Leaf)" } }

    # Loop through each profile on the machine
    Foreach ($UserProfile in $UserProfiles) {
        # Load User ntuser.dat if it's not already loaded
        If (($ProfileWasLoaded = Test-Path -Path "Registry::HKEY_USERS$($UserProfile.SID)") -eq $false) {
            Start-Process -FilePath "cmd.exe" -ArgumentList "/C reg.exe LOAD HKU$($UserProfile.SID) $($UserProfile.UserHive)" -Wait -WindowStyle Hidden
        }

        # Read the user's registry
        $Path | ForEach-Object {
            $Key = Join-Path -Path "Registry::HKEY_USERS$($UserProfile.SID)" -ChildPath $($_)
            $Value = Get-ItemProperty -Path $Key -ErrorAction SilentlyContinue | Select-Object $Name -ExpandProperty $Name -ErrorAction SilentlyContinue
            if (
                (
                    $_ -like "*15.0*" -and
                    $Value -ne 1 -and
                    $(Test-Path -Path $Key -ErrorAction SilentlyContinue)
                ) -or
                (
                    $_ -like "*16.0*" -and
                    $Value -eq 0
                )
            ) {
                Write-Host "$($UserProfile.UserName) ModernAuth is not enabled."
                $Script:FoundModernAuthDisabled = $true
            }
        }
 
        # Unload NTuser.dat
        If ($ProfileWasLoaded -eq $false) {
            [gc]::Collect()
            Start-Sleep 1
            Start-Process -FilePath "cmd.exe" -ArgumentList "/C reg.exe UNLOAD HKU$($UserProfile.SID)" -Wait -WindowStyle Hidden | Out-Null
        }
    }
    if ($FoundModernAuthDisabled) {
        Write-Output $false
        exit 1
    }
    else {
        Write-Output $true
        exit 0
    }
}
end {}

 

Få tillgång till över 300+ skript i NinjaOne Dojo

Få tillgång till

Hur IT-proffs kan dra nytta av detta

Scriptet är inte bara ett verktyg, det är en lösning som är skräddarsydd för IT-proffs. Så här kan det förändra spelplanen:

  1. Proaktiv övervakning: Innan en potentiell säkerhetslucka blir ett fullskaligt problem kan IT-personal med hjälp av skriptet identifiera och åtgärda fall där modern autentisering är inaktiverad.
  2. Effektivitet när den är som bäst: Tiden är av yttersta vikt inom IT. Skriptet automatiserar den annars tråkiga processen att individuellt kontrollera varje användarprofil, vilket frigör värdefull tid.
  3. Tydlighet och riktning: Inga fler gissningar. Skriptet ger tydlig feedback om vilka användarprofiler som behöver uppmärksammas, vilket banar väg för riktade och effektiva åtgärder.

NinjaOne: Din partner för IT-hantering

Skriptet erbjuder en fokuserad lösning, men genom att integrera det med en omfattande IT-hanteringsplattform som NinjaOne förstärks dess kapacitet. NinjaOne tillhandahåller en enhetlig plattform som förenklar IT-driften. När det gäller modern autentisering i Office 365 kan NinjaOne sömlöst köra skriptet vid schemalagda intervall. Resultatet? Realtidsvarningar till IT-team om eventuella avvikelser, vilket säkerställer att säkerheten förblir kompromisslös.

Avslutande tankar

I den ständigt föränderliga IT-världen är modern autentisering i Office 365 inte bara en funktion – det är en nödvändighet. Genom att utnyttja det diskuterade skriptet och integrera det med robusta lösningar som NinjaOne kan IT-personal stärka sitt försvar och se till att deras organisationer alltid ligger steget före i cybersäkerhetsspelet.

Next Steps

Building an efficient and effective IT team requires a centralized solution that acts as your core service delivery tool. NinjaOne enables IT teams to monitor, manage, secure, and support all their devices, wherever they are, without the need for complex on-premises infrastructure.

Learn more about NinjaOne Remote Script Deployment, book a demo, or start your free trial of the NinjaOne platform.

Kategorier:

Du kanske även gillar