Grupo O365 y Team
Enviado por cesar.dc80 • 24 de Agosto de 2020 • Apuntes • 3.950 Palabras (16 Páginas) • 111 Visitas
$host.UI.RawUI.WindowTitle = "Group & Teams Creation"
###################### Connect to Exchange Online PowerShell ######################
Clear-host
""
Write-Host -ForegroundColor Blue -BackgroundColor Black "Exchange " -NoNewline
Write-Host -ForegroundColor Yellow -BackgroundColor Black "Online Powershell Module & " -NoNewline
Write-Host -ForegroundColor Magenta -BackgroundColor Black "Teams " -NoNewline
Write-Host -ForegroundColor Yellow -BackgroundColor Black "PowerShell Module Must be Installed for the Script to Run Successfully"
Start-Sleep -Seconds 3
$CreateEXOPSSession = (Get-ChildItem -Path $env:userprofile -Filter CreateExoPSSession.ps1 -Recurse -ErrorAction SilentlyContinue -Force | Select-Object -Last 1).DirectoryName
. "$CreateEXOPSSession\CreateExoPSSession.ps1"
Connect-EXOPSSession
###################### Setting the variables for 'GroupName' , 'Alias' ######################
do{
do{
do{
Clear-Host
""
Write-host -ForegroundColor Magenta "---------------------------------------------------------------------"
Write-host -ForegroundColor Magenta " Team Creation Script "
Write-host -ForegroundColor Magenta "---------------------------------------------------------------------"
""
Write-Host -ForegroundColor Yellow "WARNING - Currently only basic checks are completed in the script, please check for Similar or Existing Groups beforehand"
""
""
Write-host -ForegroundColor Cyan " New Group Information "
Write-host -ForegroundColor Cyan "---------------------------------------------------------------------"
""
$Groupname = Read-Host "Enter New Group Name"
""
Write-Host -ForegroundColor Yellow "An Alias Should " -NoNewline
Write-Host -ForegroundColor Red -BackgroundColor Black "NOT" -NoNewline
Write-Host -ForegroundColor Yellow " Contain Any Spaces Or Special Characters!"
""
Start-Sleep -Seconds 3
$Alias = Read-Host "Enter New Group Alias"
if($Alias -match " ")
{
Write-Host -ForegroundColor Yellow "Alias Contains a Space or Special character - Please Try Again"
Start-Sleep -Seconds 2
}}
While($Alias -match " ")
""
###################### Check to see if Group already exists ######################
Write-Host -ForegroundColor DarkCyan "Checking if the Group Name is already Taken..."
""
start-sleep -seconds 2
$GroupCheck = Get-UnifiedGroup -Identity $GroupName -ErrorAction SilentlyContinue
If(!$GroupCheck)
{Write-Host -ForegroundColor Green "Group Check complete, no EXACT matches found"
Start-Sleep -Seconds 2
Write-Host -ForegroundColor Green "Resuming Group Creation..."
start-sleep -seconds 2}
Else{Write-Output $GroupCheck
""
Start-Sleep -Seconds 2
Write-Host -ForegroundColor Yellow "Existing Group Found, please use another Name"
""
Start-Sleep -Seconds 3
}
}
While ($null -ne $GroupCheck -or $null -eq $Groupname)
""
###################### Set Group Type. error check for 1-4 only ######################
""
Write-host -ForegroundColor Cyan " Group Type Informattion "
Write-host -ForegroundColor Cyan "---------------------------------------------------------------------"
do {
""
Write-Host -ForegroundColor DarkCyan "Please Select the Group type from the list below:"
""
write-output "[1] - Business Unit"
""
write-output "[2] - Community of Practice"
""
write-output "[3] - Organizational Group"
""
write-output "[4] - Project"
""
[int]$GroupType = Read-Host "Select the GroupType, 1 - 4, from the above"
} until (($GroupType -ge 1) -and ($GroupType -le 4))
""
start-sleep -seconds 2
Write-Host -ForegroundColor DarkCyan "Setting selected Group type to be applied..."
switch ($grouptype) {
"1" {$metadata = '{"GroupType":"Business Unit"}'; break}
"2" {$metadata = '{"GroupType":"Community of Practice"}'; break}
"3" {$metadata = '{"GroupType":"Organizational Group"}'; break}
"4" {$metadata = '{"GroupType":"Project"}'; break}
}
""
start-sleep -seconds 2
Write-Host -ForegroundColor Green "Group Type has been set Set."
""
""
###################### Creating Array of Members and Owners to be added ######################
Write-host
...