2015-05-01 101 views
-1

我目前使用Powershell來創建一個腳本,將自動添加用戶和許可證,而不是使用GUI。我目前使用MSOnline和MsolService。我試圖做的是讓它自動登錄,而不是調出登錄窗口。 這是彈出的窗口。我只需要它自動填寫憑證並繼續。MSonline Active Directory自動登錄

enter image description here

+0

您是否嘗試過使用'-Credential'參數?請參閱https://msdn.microsoft.com/en-us/library/azure/dn194123.aspx – Matt

回答

0

這是工作代碼!

$User = 「xxxxxx」 
    $Pass = 「xxxxxx」 
    $Cred = New-Object System.Management.Automation.PsCredential($User,(ConvertTo-SecureString $Pass -AsPlainText -Force)) 
    Import-Module MSOnline 
    Connect-MsolService -Credential $Cred 
    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $Cred -Authentication Basic -AllowRedirection 
    Import-PSSession $Session 
相關問題