Remove Email param

Signed-off-by: Luke Tainton <luke@tainton.uk>
This commit is contained in:
2020-03-24 19:45:20 +00:00
parent bfb9301aef
commit 78311a0fcb
2 changed files with 25 additions and 15 deletions

View File

@@ -6,21 +6,16 @@ Function Import-TeamsUsers {
.DESCRIPTION
Import-TeamsUsers is a Powershell function that will enrol users from a CSV file into a given Microsoft Teams group.
It has two required parameters (switches): -Email and -File.
.PARAMETER Email
Your Office 365 email address. This is used to list your teams.
It has one required parameter: -File.
.PARAMETER File
The path to the CSV file that contains your users. Can either be an absolute path or relative path.
.EXAMPLE
Import-TeamsUsers -Email "user@domain.com" -File "users.csv"
Import-TeamsUsers -File "users.csv"
#>
Param(
[parameter(Mandatory=$true, position=0, ParameterSetName='Params', HelpMessage="Specify your Office 365 email address")]
[string]$Email,
[parameter(Mandatory=$true, position=1, ParameterSetName='Params', HelpMessage="Specify CSV file")]
[string]$File
)
@@ -33,7 +28,7 @@ Function Import-TeamsUsers {
##### CHECK MODULE IS INSTALLED AND IMPORTED #####
if (Get-Module -ListAvailable -Name MicrosoftTeams) {
Import-Module -Name MicrosoftTeams
Connect-MicrosoftTeams
$Email = (Connect-MicrosoftTeams -Verbose:$false).Account
} else {
Write-Host -ForegroundColor Red "Module MicrosoftTeams doesn't exist. Please run 'Install-Module -Name MicrosoftTeams' and retry."
Exit
@@ -42,8 +37,22 @@ Function Import-TeamsUsers {
Process {
##### GET USER'S TEAMS #####
Get-Team -User $Email | Select-Object -Property GroupId, DisplayName | Format-Table -AutoSize
$GroupId = Read-Host -Prompt "Paste the GroupId of the desired group"
Clear-Host
Write-Host -ForegroundColor Green "Getting your teams - please wait"
$EligibleTeams = @()
Get-Team -User $Email | ForEach-Object {
$CTeamId = $_.GroupId
$CTeamName = $_.DisplayName
If (Get-TeamUser -GroupId $CTeamId | Select-Object -Property User,Role | Where-Object {$_.User -eq $Email} | Where-Object {$_.Role -eq "owner"}) {
$EligibleTeams += @{GroupId = $CTeamId; DisplayName = $CTeamName}
}
Clear-Variable -Name CTeamId
Clear-Variable -Name CTeamName
}
Clear-Host
Write-Host "Teams that you own:"
$EligibleTeams | ForEach {[PSCustomObject]$_} | Format-Table 'GroupId', 'DisplayName' -AutoSize
$GroupId = Read-Host -Prompt "GroupId of the desired group"
##### ENROL USERS #####
$global:UsersAdded = 0;