
Hello there,
PowerShell script that takes a list of users as input and pauses OneDrive sync for each user:
$users = Get-Content -Path "C:\Path\to\UserList.txt" # Update the file path with your user list
ForEach ($user in $users) {
$onedrivePath = "C:\Users\$user\OneDrive" # Update the path if your OneDrive folder has a different location
if (Test-Path -Path $onedrivePath) {
Write-Host "Pausing OneDrive sync for user: $user"
Set-ItemProperty -Path "HKCU:\Software\Microsoft\OneDrive" -Name "DisableFileSyncNGSC" -Value 1
Stop-Process -Name "OneDrive" -ErrorAction SilentlyContinue
} else {
Write-Host "OneDrive folder not found for user: $user"
}
}
Instructions for using the script:
Create a text file containing the list of user names, with each user name on a separate line. Save it as "UserList.txt" or update the file path in the script accordingly.
Open a text editor, such as Notepad, and paste the script into a new file.
Save the file with a ".ps1" extension, such as "PauseOneDriveSync.ps1".
Open PowerShell with administrative privileges.
Navigate to the directory where you saved the script using the cd command.
Execute the script by running .\PauseOneDriveSync.ps1. If prompted, allow the script to run by adjusting the execution policy if necessary.
I used AI provided by ChatGPT to formulate part of this response. I have verified that the information is accurate before sharing it with you.
Hope this resolves your Query !!
--If the reply is helpful, please Upvote and Accept it as an answer--