2012-01-28 19 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