none
How to Auto Login to Microsoft Office (With New License Every time On Azure Windows Server 2012) RRS feed

  • Question

  • I want to use azure windows server virtual machine and run Microsoft office as a part of documents to pdf conversion project.

    The Issue is Every time Load Balancers create a new instance of Windows VM during scalability rise i want to know how do i Auto Login To Microsoft Office 365 running on Terminal Services in The Windows VM.


    Wednesday, July 17, 2019 1:06 PM

All replies

  • Hello jainalgosaliya

    We believe you require non-interactive logon to Office365 infra. The following code should work in your case. However in this case you would be saving the global admin password/user password which is a bad idea from security perspective. We would never suggest to store password in a Powershell script even on a server. 

    Import-Module MSOnline
    $pass= convertto-securestring "Password" -asplaintext -force
    $mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist $args[1],$pass
    $O365Cred = Get-Credential $mycred
    Connect-MsolService -Credential $O365Cred
    $accountskuid=Get-MsolAccountSku | select  AccountSkuId
    New-Msoluser -userPrincipalName $args[2] -displayname $args[3] -firstname $args[4] -lastname $args[5] -password $args[6] -usagelocation "us" -LicenseAssignment $args[7]

    From a security perspective , we do not suggest this however the above must do the trick. Please let us know in case it worked. 

    Thank you. 


    Please take a moment to "Mark as Answer" and/or "Vote as Helpful" wherever applicable. Thanks!!


    Tuesday, July 23, 2019 1:37 PM