Anthony K O365
asked on
Pass-through User and Password Credential for O365 Cloud session
I have a script that creates session to Office 365. However I need a way to include the credentials without always having to type it in. Can someone assist?
thanks!
thanks!
I'm assuming you're talking about connecting to the PowerShell back end of Office 365. Are you set up with standalone "In-Cloud" accounts, or using ADFS/DirSync?
ASKER
Using Dirsync
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Using the above method has the downside of having the credentials viewable in plain text, so you might consider storing them securely instead:
Then simply encrypt the password.txt file. To reuse the credentials in the script, include this:
And so on for the rest of the connections.
$x = Get-Credential
$x.Password | ConvertFrom-SecureString | Set-Content C:\password.txt
Then simply encrypt the password.txt file. To reuse the credentials in the script, include this:
$encrypted = Get-Content C:\password.txt | ConvertTo-SecureString
$credential = New-Object System.Management.Automation.PsCredential("user@domain.com", $encrypted)
Import-Module MSOnline
Connect-MsolService -Credential $credential
And so on for the rest of the connections.
ASKER
this worked ideally.
thanks!
thanks!