Search code examples
powershelloffice365user-management

How to restrict access to Office365 services for hourly employees?


I need to figure out how to restrict access to Office365 services for our hourly employees. We sync using DirSync only - we don't have ADFS. I'm hoping there is some powershell command I can run on a schedule that can disable their account at 5:00pm and enable their account at 8:00am every work day.


Solution

  • You can use Set-MsolUser like this to disable users completely:

    Set-MsolUser -UserPrincipalName <User Principal Name> -blockcredential $True
    

    But you can also control the access more granular. For more Info look here: Disable access to service