28 Commits
v1.1 ... main

Author SHA1 Message Date
d64087546d Update actions/stale action to v10 (#15)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [actions/stale](https://github.com/actions/stale) | action | major | `v1` → `v10` |

---

### Release Notes

<details>
<summary>actions/stale (actions/stale)</summary>

### [`v10`](https://github.com/actions/stale/compare/v9...v10)

[Compare Source](https://github.com/actions/stale/compare/v9...v10)

### [`v9`](https://github.com/actions/stale/compare/v8...v9)

[Compare Source](https://github.com/actions/stale/compare/v8...v9)

### [`v8`](https://github.com/actions/stale/compare/v7...v8)

[Compare Source](https://github.com/actions/stale/compare/v7...v8)

### [`v7`](https://github.com/actions/stale/compare/v6...v7)

[Compare Source](https://github.com/actions/stale/compare/v6...v7)

### [`v6`](https://github.com/actions/stale/compare/v5...v6)

[Compare Source](https://github.com/actions/stale/compare/v5...v6)

### [`v5`](https://github.com/actions/stale/compare/v4...v5)

[Compare Source](https://github.com/actions/stale/compare/v4...v5)

### [`v4`](https://github.com/actions/stale/compare/v3...v4)

[Compare Source](https://github.com/actions/stale/compare/v3...v4)

### [`v3`](https://github.com/actions/stale/compare/v2...v3)

[Compare Source](https://github.com/actions/stale/compare/v2...v3)

### [`v2`](https://github.com/actions/stale/compare/v1...v2)

[Compare Source](https://github.com/actions/stale/compare/v1...v2)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi43MS4wIiwidXBkYXRlZEluVmVyIjoiNDIuNzEuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Reviewed-on: #15
Co-authored-by: renovate[bot] <renovate-bot@git.tainton.uk>
Co-committed-by: renovate[bot] <renovate-bot@git.tainton.uk>
2026-01-05 14:06:58 +00:00
0da69f95ac Update JasonEtco/is-sponsor-label-action action to v2 (#16)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [JasonEtco/is-sponsor-label-action](https://github.com/JasonEtco/is-sponsor-label-action) | action | major | `v1` → `v2` |

---

### Release Notes

<details>
<summary>JasonEtco/is-sponsor-label-action (JasonEtco/is-sponsor-label-action)</summary>

### [`v2`](https://github.com/JasonEtco/is-sponsor-label-action/compare/v1...v2)

[Compare Source](https://github.com/JasonEtco/is-sponsor-label-action/compare/v1...v2)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi43MS4wIiwidXBkYXRlZEluVmVyIjoiNDIuNzEuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Reviewed-on: #16
Co-authored-by: renovate[bot] <renovate-bot@git.tainton.uk>
Co-committed-by: renovate[bot] <renovate-bot@git.tainton.uk>
2026-01-05 14:06:14 +00:00
f66e33535e Configure Renovate (#14)
Welcome to [Renovate](https://github.com/renovatebot/renovate)! This is an onboarding PR to help you understand and configure settings before regular Pull Requests begin.

🚦 To activate Renovate, merge this Pull Request. To disable Renovate, simply close this Pull Request unmerged.

---
### Detected Package Files

 * `.archive/.github/workflows/autobranch.yml` (github-actions)
 * `.archive/.github/workflows/sponsors.yml` (github-actions)
 * `.archive/.github/workflows/stale.yml` (github-actions)

### What to Expect

With your current configuration, Renovate will create 2 Pull Requests:

<details>
<summary>Update actions/stale action to v10</summary>

  - Schedule: ["at any time"]
  - Branch name: `renovate/actions-stale-10.x`
  - Merge into: `main`
  - Upgrade [actions/stale](https://github.com/actions/stale) to `v10`

</details>

<details>
<summary>Update JasonEtco/is-sponsor-label-action action to v2</summary>

  - Schedule: ["at any time"]
  - Branch name: `renovate/jasonetco-is-sponsor-label-action-2.x`
  - Merge into: `main`
  - Upgrade [JasonEtco/is-sponsor-label-action](https://github.com/JasonEtco/is-sponsor-label-action) to `v2`

</details>

---

 Got questions? Check out Renovate's [Docs](https://docs.renovatebot.com/), particularly the Getting Started section.
If you need any further assistance then you can also [request help here](https://github.com/renovatebot/renovate/discussions).

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).

<!--renovate-config-hash:94693a990c975907e7f13da3309b9d56ba02b3983519b41786edf5cf031e457c-->

Reviewed-on: #14
Co-authored-by: renovate[bot] <renovate-bot@git.tainton.uk>
Co-committed-by: renovate[bot] <renovate-bot@git.tainton.uk>
2026-01-05 13:48:40 +00:00
43db46bcca feat(migration): Migrate to Gitea 2026-01-05 13:42:22 +00:00
2a31da6305 📝 Remove section on now-defunct mailing list 2020-08-25 18:00:18 +01:00
db150a3973 Automatic update checking
Signed-off-by: Luke Tainton <luke@tainton.uk>
2020-08-07 23:17:24 +01:00
ab72c8c2ba Add optional -Encoding flag
Signed-off-by: Luke Tainton <luke@tainton.uk>
2020-08-07 17:47:08 +01:00
20307da1e3 🔖 Update version to 2.2.0
Signed-off-by: Luke Tainton <luke@tainton.uk>
2020-08-07 17:47:08 +01:00
5bdf885036 Add optional Delimiter flag
Signed-off-by: Luke Tainton <luke@tainton.uk>
2020-08-07 17:47:08 +01:00
9fb651f29d Update README.md 2020-07-04 19:32:53 +01:00
218f6cc3a5 Add mailing list info to README 2020-07-04 19:15:27 +01:00
aef71bb6c8 Create stale.yml 2020-06-01 15:46:39 +01:00
ead4d470f7 🐛 FIX: Fix hardcoded description for new teams
Signed-off-by: Luke Tainton <luke@tainton.uk>
2020-05-28 14:33:08 +01:00
c383fb840d Update TeamsUserEnroller.psd1 2020-05-19 15:49:37 +01:00
1d7e7c71b7 Update README.md 2020-05-19 15:44:49 +01:00
cb3d1eb3bd 👌 IMPROVE: Allow creation of new group
Signed-off-by: Luke Tainton <luke@tainton.uk>
2020-05-19 15:44:49 +01:00
42fdf856b5 Revert "Create secrets.yml"
This reverts commit 6b13a2d1fc.
2020-05-18 19:07:36 +01:00
6b13a2d1fc Create secrets.yml 2020-05-18 19:03:04 +01:00
2056117ea7 DOC: Fix README typo 2020-04-27 12:34:42 +01:00
0f8b9dfdea Update README.md 2020-04-27 12:34:02 +01:00
eba04be5f3 ACTIONS: Create Auto Branch 2020-04-23 12:30:26 +01:00
a88fb454fa ACTIONS: Create Sponsors 2020-04-23 12:17:08 +01:00
44a90b2c52 Create issue-branch.yml 2020-04-23 11:23:19 +01:00
412966ec1d BREAKING: Rename module (#4) 2020-04-21 19:14:14 +01:00
99718ae5aa 📖 DOC: Module published to PowerShell Gallery
Signed-off-by: Luke Tainton <luke@tainton.uk>
2020-04-18 20:07:09 +01:00
b2ea10d113 Merge branch 'master' of github.com:luketainton/Import-TeamsUsers 2020-04-18 19:47:06 +01:00
5b1a4dd1d1 🚀 RELEASE: Add manifest file for publishing
Signed-off-by: Luke Tainton <luke@tainton.uk>
2020-04-18 19:46:52 +01:00
58e5ed94b6 Add examples to CSV 2020-03-30 15:59:17 +01:00
11 changed files with 380 additions and 100 deletions

9
.archive/.github/issue-branch.yml vendored Normal file
View File

@@ -0,0 +1,9 @@
mode: auto
silent: false
branchName: short
branches:
- label: feature
prefix: feature/
- label: bug
prefix: bug/
autoCloseIssue: true

View File

@@ -0,0 +1,14 @@
on:
issues:
types: [assigned]
issue_comment:
types: [created]
jobs:
create_issue_branch_job:
runs-on: ubuntu-latest
steps:
- name: Create Issue Branch
uses: robvanderleek/create-issue-branch@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

14
.archive/.github/workflows/sponsors.yml vendored Normal file
View File

@@ -0,0 +1,14 @@
name: Label sponsors
on:
pull_request:
types: [opened]
issues:
types: [opened]
jobs:
build:
name: is-sponsor-label
runs-on: ubuntu-latest
steps:
- uses: JasonEtco/is-sponsor-label-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

19
.archive/.github/workflows/stale.yml vendored Normal file
View File

@@ -0,0 +1,19 @@
name: Mark stale issues and pull requests
on:
schedule:
- cron: "0 0 * * *"
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v10
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue has been marked as stale due to inactivity. If this issue is still ongoing, please leave a comment.'
stale-pr-message: 'This pull request has been marked as stale due to inactivity. If this PR is still ongoing, please leave a comment.'
stale-issue-label: 'status/stale'
stale-pr-label: 'status/stale'

1
.gitea/CODEOWNERS Normal file
View File

@@ -0,0 +1 @@
* @luke

View File

@@ -1,85 +0,0 @@
Function Import-TeamsUsers {
<#
.SYNOPSIS
Import-TeamsUsers is a Powershell function that will enrol users from a CSV file into a given Microsoft Teams group.
.DESCRIPTION
Import-TeamsUsers is a Powershell function that will enrol users from a CSV file into a given Microsoft Teams group.
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 -File "users.csv"
#>
Param(
[parameter(Mandatory=$true, position=1, ParameterSetName='Params', HelpMessage="Specify CSV file")]
[string]$File
)
Begin {
$ErrorActionPreference = 'Stop'
##### IMPORT CSV FILE #####
$Users = Import-CSV $File
##### CHECK MODULE IS INSTALLED AND IMPORTED #####
if (Get-Module -ListAvailable -Name MicrosoftTeams) {
Import-Module -Name 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
}
}
Process {
##### GET USER'S TEAMS #####
Clear-Host
Write-Host -ForegroundColor Green "Getting your teams - please wait"
$EligibleTeams = @()
Get-Team -User $Email -Verbose:$false | 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-Object {[PSCustomObject]$_} | Format-Table 'GroupId', 'DisplayName' -AutoSize
$GroupId = Read-Host -Prompt "GroupId of the desired group"
##### ENROL USERS #####
$global:UsersAdded = 0;
$UserCount = $Users | Measure-Object | Select-Object -expand count
$Consent = Read-Host -Prompt "You are about to add $UserCount users. Are you sure? [y/N]"
If ($Consent -eq "y" -Or $Consent -eq "Y") {
$Users | ForEach-Object {
$User = $_.email
$Role = $_.role
Try {
Add-TeamUser -GroupId $GroupId -Role $Role -User $User
Write-Host "Added user $User with role $Role"
$global:UsersAdded++
} Catch [Microsoft.TeamsCmdlets.PowerShell.Custom.ErrorHandling.ApiException] {
Write-Host -ForegroundColor Red "Error adding user $User with role $Role"
}
Clear-Variable -Name User
Clear-Variable -Name Role
}
Write-Host -ForegroundColor Green "$global:UsersAdded users added successfully."
} Else {
Write-Host -ForegroundColor Red "Aborting."
}
}
End {
@('UserCount', 'UsersAdded', 'Consent', 'Users', 'GroupId') | ForEach-Object {Clear-Variable -Name $_}
Disconnect-MicrosoftTeams
}
}

View File

@@ -1,21 +1,30 @@
# Import-TeamsUsers
A Powershell script that imports users from a CSV into a Microsoft Teams team.
# TeamsUserEnroller
A Powershell module that imports users from a CSV into a Microsoft Teams group.
# Setting up your device
This script runs via PowerShell. If you're on Windows, you'll already have this. If not, please download it from the [releases page](https://github.com/PowerShell/PowerShell/releases). Once you've got PowerShell:
This module uses PowerShell, which is pre-installed on Windows. If you're not on Windows, please [download **PowerShell Core**](https://github.com/PowerShell/PowerShell/releases).
1. Open PowerShell as an administrator.
2. Allow remote scripts to execute by running `Set-ExecutionPolicy RemoteSigned`. If you don't do this, the script won't run.
3. Install the Microsoft Teams module. To do this, run `Install-Module -Name MicrosoftTeams`. Accept any prompts that you are given.
1. Install this module by running `Install-Module -Name TeamsUserEnroller`.
# Running the script
1. Download the repository to your PC.
2. Create a CSV file in the format `email,role`. The first line must be the headers `email,role`. You can copy the template if required.
3. Open PowerShell and change directory (`cd`) to the directory where you downloaded the repository.
3. Import the module (`Import-Module ./Import-TeamsUsers.psm1`).
4. Run `Import-TeamsUsers -File <FILE>`.
1. Create a CSV file containing your users and their desired roles. The first line must be the headers `email,role`, for example:
```csv
email,role
jbloggs@example.com,owner
user@example.com,member
```
1. Run `Import-TeamsUsers -File <FILE>`, where `<FILE>` is the path to the CSV file. You can add the `-Create` flag if you want to create a new team first.
### If you can't run non-signed scripts
If your policy requires scripts to be digitally signed, run
```powershell
Set-ExecutionPolicy Bypass -Scope Process
```
then try running the command again. You may require administrative rights to change the Execution Policy.
# Need help?
If you require assistance running the script, see the help by executing `Get-Help Import-TeamsUsers` (requires importing the module first - see steps 3 and 4 above). If you still need help, please [send me an email](mailto:luke@tainton.uk?subject=I%20need%20help%20running%20Import-TeamsUsers).
# Issues? Want a new feature?
If you're having problems with the script or have an idea for a new feature, please check [here](https://github.com/luketainton/Import-TeamsUsers/issues) to see if someone else has the same problem or suggestion, and open an issue if one doesn't already exist. If you can implement a fix or feature request, please file a pull request!
If you need assistance, please try the following:
1. See the help documentation by running `Get-Help Import-TeamsUsers`.
1. Check closed issues [here](https://git.tainton.uk/repos/TeamsUserEnroller/issues?type=all&state=closed).
1. Open an issue [here](https://git.tainton.uk/repos/TeamsUserEnroller/issues/new).

132
TeamsUserEnroller.psd1 Normal file
View File

@@ -0,0 +1,132 @@
#
# Module manifest for module 'TeamsUserEnroller'
#
# Generated by: Luke Tainton
#
# Generated on: 21/04/2020
#
@{
# Script module or binary module file associated with this manifest.
# RootModule = ''
# Version number of this module.
ModuleVersion = '2.2.1'
# Supported PSEditions
# CompatiblePSEditions = @()
# ID used to uniquely identify this module
GUID = 'a7b4e6d0-c92e-40df-a238-2b7a131a13a1'
# Author of this module
Author = 'Luke Tainton'
# Company or vendor of this module
CompanyName = 'Luke Tainton'
# Copyright statement for this module
Copyright = '(c) 2020 Luke Tainton. All rights reserved.'
# Description of the functionality provided by this module
Description = 'A Powershell module that will enrol users from a CSV file into a given Microsoft Teams group.'
# Minimum version of the PowerShell engine required by this module
# PowerShellVersion = ''
# Name of the PowerShell host required by this module
# PowerShellHostName = ''
# Minimum version of the PowerShell host required by this module
# PowerShellHostVersion = ''
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# CLRVersion = ''
# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''
# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @('MicrosoftTeams')
# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()
# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()
# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
NestedModules = @('./TeamsUserEnroller.psm1')
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @('Import-TeamsUsers')
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = '*'
# Variables to export from this module
VariablesToExport = '*'
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = '*'
# DSC resources to export from this module
# DscResourcesToExport = @()
# List of all modules packaged with this module
# ModuleList = @()
# List of all files packaged with this module
FileList = @('./TeamsUserEnroller.psm1')
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
PSData = @{
# Tags applied to this module. These help with module discovery in online galleries.
Tags = @('Teams', 'Skype', 'Office365')
# A URL to the license for this module.
# LicenseUri = ''
# A URL to the main website for this project.
ProjectUri = 'https://github.com/luketainton/TeamsUserEnroller'
# A URL to an icon representing this module.
# IconUri = ''
# ReleaseNotes of this module
ReleaseNotes = 'https://github.com/luketainton/TeamsUserEnroller/releases'
# Prerelease string of this module
# Prerelease = ''
# Flag to indicate whether the module requires explicit user acceptance for install/update/save
RequireLicenseAcceptance = $false
# External dependent modules of this module
# ExternalModuleDependencies = @()
} # End of PSData hashtable
} # End of PrivateData hashtable
# HelpInfo URI of this module
# HelpInfoURI = ''
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''
}

165
TeamsUserEnroller.psm1 Normal file
View File

@@ -0,0 +1,165 @@
Function Import-TeamsUsers {
<#
.SYNOPSIS
Import-TeamsUsers is a Powershell function that will enrol users from a CSV file into a given Microsoft Teams group.
.DESCRIPTION
Import-TeamsUsers is a Powershell function that will enrol users from a CSV file into a given Microsoft Teams group.
.PARAMETER File
The path to the CSV file that contains your users. Can either be an absolute path or relative path.
.PARAMETER Create
If specified, create a new Group first, then add the users from the CSV file.
.PARAMETER Delimiter
If specified, overrides the default CSV delimiter of ','.
.PARAMETER Encoding
If specified, manually sets the encoding of the CSV file.
.EXAMPLE
Import-TeamsUsers -File "users.csv"
.EXAMPLE
Import-TeamsUsers -Create -File "users.csv"
#>
Param(
[parameter(Mandatory=$true, position=1, ParameterSetName='Params', HelpMessage="Specify CSV file")]
[string]$File,
[parameter(Mandatory=$false, position=2, ParameterSetName='Params', HelpMessage="Create new Teams group")]
[switch]$Create,
[parameter(Mandatory=$false, position=3, ParameterSetName='Params', HelpMessage="Override default CSV delimiter")]
[string]$Delimiter,
[parameter(Mandatory=$false, position=4, ParameterSetName='Params', HelpMessage="Manually set CSV encoding")]
[string]$Encoding
)
Begin {
$ErrorActionPreference = 'Stop'
##### CHECK FOR NEW VERSION #####
Try {
# Get information from GitHub Releases
$releases = Invoke-RestMethod -Method Get -Uri "https://api.github.com/repos/luketainton/TeamsUserEnroller/releases";
$rel = $releases[0];
$latest_version = $rel.tag_name -replace 'v', '';
$latest_version_changes = $rel.body;
# Get currently installed version
$current_version = (Get-Module TeamsUserEnroller | Select-Object Version).Version;
# Compare versions and alert user if newer version available
if ($current_version -lt $latest_version) {
Write-Host -ForegroundColor Yellow "A new version of TeamsUserEnroller has been released!";
Write-Host -ForegroundColor Yellow "Latest version: $latest_version";
Write-Host -ForegroundColor Yellow "Installed version: $current_version";
Write-Host -ForegroundColor Yellow "`n$latest_version_changes";
$Consent = Read-Host -Prompt "`nWould you like to update now? [y/N]"
If ($Consent -eq "y" -Or $Consent -eq "Y") {
Update-Module -Name TeamsUserEnroller -RequiredVersion "2.2.0";
$after_update_ver = (Get-Module TeamsUserEnroller | Select-Object Version).Version;
if ($after_update_ver -eq $latest_version) {
Write-Host -ForegroundColor Green "Update completed.";
} Else {
Write-Host -ForegroundColor Red "Update failed. Please update manually.";
}
}
}
} Catch {
Write-Host -ForegroundColor Red "An error occurred while checking for updates. Continuing.";
}
##### IMPORT CSV FILE #####
Try {
$ImportCmd = "Import-CSV $File"
If ($Delimiter) { $ImportCmd = $ImportCmd + " -Delimiter $Delimiter" }
If ($Encoding) { $ImportCmd = $ImportCmd + " -Encoding $Encoding" }
$Users = Invoke-Expression $ImportCmd
} Catch {
Write-Host -ForegroundColor Red "$File is not a valid CSV file."
Exit
}
##### CHECK MODULE IS INSTALLED AND IMPORTED #####
if (Get-Module -ListAvailable -Name MicrosoftTeams) {
try {
Import-Module -Name MicrosoftTeams
$Email = (Connect-MicrosoftTeams -Verbose:$false).Account
} Catch {
Write-Host -ForegroundColor Red "There was an error during authentication."
Write-Host "If you're not on Windows and use Multi-Factor Authentication, please manually pass the MFA check in your browser, then try again."
Exit
}
} else {
Write-Host -ForegroundColor Red "Module MicrosoftTeams doesn't exist. Please run 'Install-Module -Name MicrosoftTeams' and retry."
Exit
}
}
Process {
If ($Create) {
##### CREATE NEW TEAM #####
Clear-Host
$NewTeamName = Read-Host -Prompt "Name of the new group"
$NewTeamDesc = Read-Host -Prompt "Group description"
$NewTeamPriv = Read-Host -Prompt "P[u]blic or P[r]ivate?"
If ($NewTeamPriv -Eq "u") {
$NewTeamVis = "Public"
} Elseif ($NewTeamPriv -Eq "r") {
$NewTeamVis = "Private"
}
$NewTeam = New-Team -DisplayName $NewTeamName -MailNickName $NewTeamName -Description $NewTeamDesc -Visibility $NewTeamVis
$GroupId = $NewTeam.GroupId
} Else {
##### GET USER'S TEAMS #####
Clear-Host
Write-Host -ForegroundColor Green "Getting your teams - please wait"
$EligibleTeams = @()
Get-Team -User $Email -Verbose:$false | 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-Object {[PSCustomObject]$_} | Format-Table 'GroupId', 'DisplayName' -AutoSize
$GroupId = Read-Host -Prompt "GroupId of the desired group"
}
##### ENROL USERS #####
$global:UsersAdded = 0;
$UserCount = $Users | Measure-Object | Select-Object -expand count
$Consent = Read-Host -Prompt "You are about to add $UserCount users. Are you sure? [y/N]"
If ($Consent -eq "y" -Or $Consent -eq "Y") {
$Users | ForEach-Object {
$User = $_.email
$Role = $_.role
Try {
Add-TeamUser -GroupId $GroupId -Role $Role -User $User
Write-Host "Added user $User with role $Role"
$global:UsersAdded++
} Catch [Microsoft.TeamsCmdlets.PowerShell.Custom.ErrorHandling.ApiException] {
Write-Host -ForegroundColor Red "Error adding user $User with role $Role"
}
Clear-Variable -Name User
Clear-Variable -Name Role
}
Write-Host -ForegroundColor Green "$global:UsersAdded users added successfully."
} Else {
Write-Host -ForegroundColor Red "Aborting."
}
}
End {
@('UserCount', 'UsersAdded', 'Consent', 'Users', 'GroupId') | ForEach-Object {Clear-Variable -Name $_}
Disconnect-MicrosoftTeams
}
}

3
renovate.json Normal file
View File

@@ -0,0 +1,3 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
}

View File

@@ -1 +0,0 @@
email,role
1 email role