Skip to content

Instantly share code, notes, and snippets.

foreach($user in $csvimport)
{
$mail = $user.$eMailField
$surname = $user.$surnameField
$givenname = $user.$givennameField
try{
$user = Get-AzureADUser -ObjectID $mail
Add-RoleGroupMember $EXORole -Member $mail
Write-Host "User added;"$mail";"$surname";"$givenname
Stop-Transcript
Disconnect-ExchangeOnline
Disconnect-AzureAD
# Create logfile
$date = Get-Date -Format FileDateTime
$logFile = $log + "roles_added_" + $date + ".txt"
Start-Transcript -Path $logFile
Read-Host "Press Enter to continue..."
# import csv
$csvimport = Import-Csv -Path $csvinputfile -Delimiter $delimiter
# Connect to Exchange Online
$Credentials = Get-Credential
Connect-ExchangeOnline -Credential $Credentials
#Connect to AzureAD
Connect-AzureAD
givenname surname E-Mail
Test User tu@sprocks.io
<Config>
<EXORole>Help Desk</EXORole>
<log>config\</log>
<csvinput>csvinput\csv1.csv</csvinput>
<delimiter>,</delimiter>
<eMailField>E-Mail</eMailField>
<givenname>Givenname</givenname>
<surname>Surname</surname>
</Config>
Write-Host "-------------------------------------------------" -ForeGroundColor Yellow
Write-Host "Loading config settings xml..." -ForeGroundColor Yellow
# Path to config File
$configFile = "config\config.xml"
# Test if config file does exist
if((Test-Path $configFile) -eq $false)
{
Write-host "Config XML not found"
#exit
###
# Danny Davis
# twitter: twitter.com/pko3
# github: github.com/pkothree
# Created: 01/27/21
# Modified: 01/27/21
# Description: add Users to a Exchange Online Role
###
Write-Host "-------------------------------------------------" -ForeGroundColor Yellow
Set-Mailbox -Identity "E-Mail-Address" -IssueWarningQuota 10gb -ProhibitSendQuota 11gb -ProhibitSendReceiveQuota 12gb -UseDatabaseQuotaDefaults $false
@pkothree
pkothree / SetOwaPolicySetPhoto.ps1
Created January 4, 2021 08:05
SetPhotoEnabled to false
Set-OwaMailboxPolicy OwaMailboxPolicy-Default -SetPhotoEnabled $false