With this short script you can Opt-Out or Opt-In users from MyAnalytics feature in MS365/Office365. Additionally you can disable MyAnalytics feature in Office365 admin panel.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Clear-Host | |
# If you have CSV file with a users, header should be UserPrincipalName | |
$theUsers = "C:\Export\Users.csv" | |
# If you want to get users from AAD directly | |
# $theusers = Get-MsolUser -All | Select UserPrincipalName | |
function setAnalytics { | |
Set-UserAnalyticsConfig -identity $user.UserPrincipalName -PrivacyMode $privacyMode -ErrorAction SilentlyContinue | |
} | |
# Privacy Mode: Opt-out or Opt-in | |
$privacyMode = "Opt-out" | |
Write-Progress -Activity "Getting users" | |
$users = Import-Csv $theUsers | |
foreach ($user in $users) { | |
Write-Host "`r`nProcessing: " -ForegroundColor Cyan | |
$user.UserPrincipalName | |
setAnalytics | |
} |