You can run the command via AD PowerShell directly: $msolcred = get-credential connect-msolservice -credential $msolcred To purge the deleted user accounts: get-msoluser –returndeletedusers -maxresults 100000 | remove-msoluser -removefromrecyclebin -force