<# .SYNOPSIS Microsoft Secure Score Hardening — Microsoft Teams & SharePoint Online (8 Kontrol) .DESCRIPTION Kod Güvenlik Sınıfı : Üretim ortamında uygulanabilir değişiklik (Teams + SharePoint PowerShell) Yetki Gereksinimi : Teams Administrator + SharePoint Administrator (veya Sertifikalı App-Only) Ön Koşul : MicrosoftTeams v6+ ve Microsoft.Online.SharePoint.PowerShell (PowerShell 7 / 5.1) Kapsanan Secure Score Maddeleri (Toplam +16 Puan): - #34 : Teams Global Meeting Policy -> AutoAdmittedUsers = InvitedUsers (+2) - #35 : Teams Global Meeting Policy -> DesignatedPresenterRoleMode = OrganizerOnlyUserOverride (+2) - #37 : Teams Global Meeting Policy -> AllowAnonymousUsersToJoinMeeting = $false (+1) - #27 : OneDrive Sync Unmanaged Device / Mac Block (+3) - #28 : SharePoint External Sharing Domain BlockList (+3) - #29 : SharePoint PreventExternalUsersFromResharing = $true (+3) - #45 : SharePoint Idle Session Sign-Out (Warn 15m / SignOut 30m) (+1) - #46 : SharePoint LegacyAuthProtocolsEnabled = $false (+1) .EXAMPLE pwsh -ExecutionPolicy Bypass -File "D:\Lab\Scripts\02-Apply-SecureScore-Teams-SPO.ps1" -TenantShortName "contoso" #> [CmdletBinding(SupportsShouldProcess = $true)] param( [string]$AppId, [string]$TenantId, [string]$CertificateThumbprint, [string]$TenantShortName, [switch]$SkipSharePoint, [string]$BlockedDomains = 'gmail.com yahoo.com hotmail.com outlook.com mail.ru' ) $ErrorActionPreference = 'Stop' # --- A. MICROSOFT TEAMS HARDENING (#34, #35, #37) --- Import-Module MicrosoftTeams -ErrorAction Stop if ($AppId -and $TenantId -and $CertificateThumbprint) { Write-Host "[1/2] Microsoft Teams sertifikalı oturum açılıyor..." -ForegroundColor Cyan Connect-MicrosoftTeams -ApplicationId $AppId -TenantId $TenantId -CertificateThumbprint $CertificateThumbprint | Out-Null } else { Write-Host "[1/2] Microsoft Teams etkileşimli oturum açılıyor..." -ForegroundColor Cyan Connect-MicrosoftTeams | Out-Null } if ($PSCmdlet.ShouldProcess("CsTeamsMeetingPolicy Global", "Enforce InvitedUsers, OrganizerOnlyUserOverride, Anonymous=False")) { Set-CsTeamsMeetingPolicy -Identity Global ` -AutoAdmittedUsers 'InvitedUsers' ` -DesignatedPresenterRoleMode 'OrganizerOnlyUserOverride' ` -AllowAnonymousUsersToJoinMeeting $false } Write-Host "`n--- Teams Canlı Doğrulama (Salt Okunur) ---" -ForegroundColor Green Get-CsTeamsMeetingPolicy -Identity Global | Select-Object Identity, AutoAdmittedUsers, DesignatedPresenterRoleMode, AllowAnonymousUsersToJoinMeeting | Format-List Disconnect-MicrosoftTeams # --- B. SHAREPOINT ONLINE HARDENING (#27, #28, #29, #45, #46) --- if (-not $SkipSharePoint) { if (-not $TenantShortName) { throw "SharePoint Online bağlantısı için -TenantShortName (ör. 'contoso') gereklidir." } Import-Module Microsoft.Online.SharePoint.PowerShell -UseWindowsPowerShell -ErrorAction Stop $spoAdminUrl = "https://$TenantShortName-admin.sharepoint.com" Write-Host "[2/2] SharePoint Online Admin ($spoAdminUrl) oturumu açılıyor..." -ForegroundColor Cyan Connect-SPOService -Url $spoAdminUrl if ($PSCmdlet.ShouldProcess("SPOTenant", "Enforce Modern Auth, Domain BlockList, PreventResharing, Idle Sign-Out")) { Set-SPOTenant ` -LegacyAuthProtocolsEnabled $false ` -PreventExternalUsersFromResharing $true ` -SharingDomainRestrictionMode BlockList ` -SharingBlockedDomainList $BlockedDomains Set-SPOBrowserIdleSignOut -Enabled $true ` -WarnAfter (New-TimeSpan -Minutes 15) ` -SignOutAfter (New-TimeSpan -Minutes 30) } Write-Host "`n--- SharePoint Canlı Doğrulama (Salt Okunur) ---" -ForegroundColor Green Get-SPOTenant | Select-Object LegacyAuthProtocolsEnabled, PreventExternalUsersFromResharing, SharingDomainRestrictionMode, SharingBlockedDomainList | Format-List Get-SPOBrowserIdleSignOut | Format-List Disconnect-SPOService }