2012-01-28 7 views
0

Как я могу установить учетные данные из моего сценария, это раздражает, чтобы каждый раз вводить мой пользователь и пароль при разработке.office 365 Set-Credential

В основном я ищу некоторую функцию, например Set-Credential.

С уважением,

ответ

1

Вы можете использовать этот скрипт:

Set-ExecutionPolicy unrestricted 
$cred = Get-Credential 
$O365 = New-PSSession -ConfigurationName Microsoft.Exchange –ConnectionUri https://ps.outlook.com/powershell -Credential $cred -Authentication Basic –AllowRedirection 
$importcmd = Import-PSSession $O365 
$importcmd.ExportedFunctions.Count 

Или вы можете использовать этот сценарий - что-то вроде этого:

$domain=YOUR_DOMAIN 
$userName = "[email protected]$domain.onmicrosoft.com" ($domain change to your domain) 
$password = "PASSWORD" 
$securePassword = ConvertTo-SecureString -String $password -AsPlainText -Force 
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $userName, $securePassword 
Connect-MsolService -Credential $credential 
0
$Cred = Get-Credential 
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 


$User = “<[email protected]>” 
$Pass = “<password>” 
$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