PowerAddict.net

powerAddict.NET

by Lou Goban
IT Application Professional at Syntax

Opt-out users from MyAnalytics

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.

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
}

Leave the first comment