-
-
Save dannneal/9dbbe9dc87b441972c91bb71663e1cdc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Connect-MicrosoftTeams | |
Get-Team -displayname "YourTeamName" | |
while($true) { | |
#Get Teams users, the one's that haven't left... | |
Get-TeamUser -GroupId (groupidhere) | Select-Object user | out-file C:\PreAddUsers.txt | |
$PreAddUsers = get-content C:\PreAddUsers.txt | |
#import the list of users who should be in the Team, add them | |
import-csv -path "C:\Thisisthelistofusers.csv" | ForEach-Object {Add-TeamUser -groupid (groupidhere) -User $_.email} | |
#Now, get the list of users in the Teams, for comparing. | |
Get-Teamuser -GroupId (groupidhere) | Select-Object user | Out-File C:\PostAddUsers.txt | |
$PostAddUsers = get-content C:\PostAddUsers.txt | |
#Compares the two lists for outputting | |
Compare-object -ReferenceObject $PreAddUsers -DifferenceObject $PostAddUsers -PassThru | Out-file C:\UserDiff.txt | |
$output = Get-Content -path C:\UserDiff.txt -raw | |
#writes the lists of users who were added back to the Team, along with the date. Then will wait for 6 hours before running again. | |
Write-host "$output" -ForegroundColor yellow | |
write-host (get-date).ToString('T') -ForegroundColor green | |
"Users added were $output" | |
start-sleep -seconds 23200 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment