Created
June 29, 2018 07:13
-
-
Save andif888/2e90a3b8be61d471be8f0c49393cba3c to your computer and use it in GitHub Desktop.
drone CI file for running a powershell container executing powershell scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipeline: | |
power-pipe: | |
image: mcr.microsoft.com/powershell:ubuntu-16.04 | |
commands: | |
- pwsh test.ps1 $O365_USERNAME $O365_PASSWORD | |
secrets: [o365_username, o365_password] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region Starting O365 Session | |
$ErrorActionPreference = "Stop" | |
$credential = $null | |
if ($args[0] -and $args[1]) | |
{ | |
$user = $args[0] | |
$pass = ConvertTo-SecureString -AsPlainText $args[1] -Force | |
Write-Host $user | |
$credential = New-Object -Type System.Management.Automation.PSCredential -ArgumentList $user,$pass | |
} | |
else | |
{ | |
$credential = Get-Credential | |
} | |
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $credential -Authentication Basic -AllowRedirection | |
Import-PSSession $Session | |
#endregion | |
$users = @() | |
$users = "[email protected]" | |
$users = "[email protected]" | |
foreach ($user in $users) | |
{ | |
Add-MailboxPermission -Identity [email protected] -AccessRights FullAccess -AutoMapping $true -User $user | |
} | |
#region Removing O365 Session | |
Remove-PSSession $Session | |
#endregion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment