Skip to content

Instantly share code, notes, and snippets.

@andif888
Created June 29, 2018 07:13
Show Gist options
  • Save andif888/2e90a3b8be61d471be8f0c49393cba3c to your computer and use it in GitHub Desktop.
Save andif888/2e90a3b8be61d471be8f0c49393cba3c to your computer and use it in GitHub Desktop.
drone CI file for running a powershell container executing powershell scripts
pipeline:
power-pipe:
image: mcr.microsoft.com/powershell:ubuntu-16.04
commands:
- pwsh test.ps1 $O365_USERNAME $O365_PASSWORD
secrets: [o365_username, o365_password]
#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 = "testuser1@prianto.com"
$users = "testuser2@prianto.com"
foreach ($user in $users)
{
Add-MailboxPermission -Identity sharedmailbox1@prianto.com -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