Please Note: I do not recommend this script, there are probably much better ways of doing this, this was my first ever “automation” attempt.
VBS Script to force the PowerShell script to run silently
command = "powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -NoLogo -NonInteractive -File C:\ProgramData\Company\OneDriveNag\OneDriveNag.ps1"
set shell = CreateObject("WScript.Shell")
shell.Run command,0
PowerShell script
Start-Sleep -s 5
$UserName= "$ENV:USERNAME"
RUNAS /trustlevel:0x20000 "C:\Users\$UserName\AppData\Local\Microsoft\OneDrive\OneDrive.exe /configure_business:ms-azure-tenant-id"
Once I created these scripts I used a GPO to copy the files over to the C:\ProgramData\Company\OneDrive\
folder and then I used the same GPO to create a scheduled task to run the VBS script on every computer login, unlock and every hour.
Because of the way OneDrive works once the user logs into their machines the prompt to login will never appear again unless they log out.