Actualiser Compte_Office.ps1
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#Prérequis :
|
# Prérequis :
|
||||||
Install-Module Microsoft.Graph -Scope CurrentUser
|
Install-Module Microsoft.Graph -Scope CurrentUser
|
||||||
Connect-MgGraph -Scopes "User.ReadWrite.All", "Directory.ReadWrite.All"
|
Connect-MgGraph -Scopes "User.ReadWrite.All", "Directory.ReadWrite.All"
|
||||||
|
|
||||||
@@ -7,27 +7,32 @@ Import-Module -Name ExchangeOnlineManagement
|
|||||||
Install-Module -Name MSOnline
|
Install-Module -Name MSOnline
|
||||||
Import-Module -Name MSOnline
|
Import-Module -Name MSOnline
|
||||||
|
|
||||||
|
# => Compte Administrateur du tenant du domaine.
|
||||||
######## CONNEXION ###########
|
######## CONNEXION ###########
|
||||||
Connect-ExchangeOnline -UserPrincipalName "*******@h3campus.fr"
|
Connect-ExchangeOnline -UserPrincipalName "*******@h3campus.fr"
|
||||||
# Domaine utilisé pour les adresses email
|
# => Domaine utilisé pour les adresses email
|
||||||
#$domain = "h3hitema.fr"
|
#$domain = "h3hitema.fr"
|
||||||
$domain = "h3campus.fr"
|
$domain = "h3campus.fr"
|
||||||
|
|
||||||
# Paramètres pour Office 365
|
# => Paramètres pour Office 365 pour l'envoie des identifiants aux étudiants
|
||||||
$smtpServer = "smtp.office365.com"
|
$smtpServer = "smtp.office365.com"
|
||||||
$smtpPort = 587
|
$smtpPort = 587
|
||||||
$smtpUser = "Compte_EnvoieMail@h3hitema.fr" # L'adresse email de l'expéditeur
|
$smtpUser = "Compte_EnvoieMail@h3hitema.fr" # L'adresse email de l'expéditeur
|
||||||
$smtpPassword = "********"
|
$smtpPassword = "********"
|
||||||
|
|
||||||
# Définir les codes de couleur
|
# => Définition du comportement pour les comptes existants
|
||||||
$red = "e[31m"
|
# Valeurs possibles : "IgnorerExistants" ou "ReinitializerMotDePasse"
|
||||||
$green = "e[32m"
|
$ComportementComptesExistants = "IgnorerExistants"
|
||||||
$reset = "`e[0m"
|
|
||||||
|
|
||||||
# Charger les informations des étudiants à partir du fichier CSV
|
# => Charger les informations des étudiants à partir du fichier CSV
|
||||||
$csvPath = "students.csv"
|
$csvPath = "students.csv"
|
||||||
$etudiants = Import-Csv -Path $csvPath
|
$etudiants = Import-Csv -Path $csvPath
|
||||||
|
|
||||||
|
# Définir les codes de couleur
|
||||||
|
$red = "`e[31m"
|
||||||
|
$green = "`e[32m"
|
||||||
|
$reset = "`e[0m"
|
||||||
|
|
||||||
function Normalize-String {
|
function Normalize-String {
|
||||||
param (
|
param (
|
||||||
[string]$inputString
|
[string]$inputString
|
||||||
@@ -139,31 +144,174 @@ function Envoyer-Email {
|
|||||||
param (
|
param (
|
||||||
[string]$destinataire,
|
[string]$destinataire,
|
||||||
[string]$login,
|
[string]$login,
|
||||||
[string]$password
|
[string]$password,
|
||||||
|
[bool]$isReset = $false
|
||||||
)
|
)
|
||||||
|
|
||||||
# Contenu de l'email avec mise en forme HTML
|
# Contenu de l'email avec mise en forme HTML moderne
|
||||||
$subject = "Compte - $domain"
|
$messageType = if ($isReset) { "Réinitialisation de votre mot de passe" } else { "Bienvenue sur votre compte $domain" }
|
||||||
|
$titre = if ($isReset) { "Réinitialisation de mot de passe" } else { "Création de compte" }
|
||||||
|
$subject = $messageType
|
||||||
$body = @"
|
$body = @"
|
||||||
<html>
|
<html>
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
|
background-color: #f4f4f4;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.email-container {
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 20px auto;
|
||||||
|
background-color: #ffffff;
|
||||||
|
border-radius: 10px;
|
||||||
|
overflow: hidden;
|
||||||
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
.header {
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
color: white;
|
||||||
|
padding: 30px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.header h1 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
.content {
|
||||||
|
padding: 30px;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
.greeting {
|
||||||
|
font-size: 18px;
|
||||||
|
color: #333;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
.info-box {
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 25px;
|
||||||
|
margin: 25px 0;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
.info-row {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin: 15px 0;
|
||||||
|
padding: 12px;
|
||||||
|
background: rgba(255, 255, 255, 0.15);
|
||||||
|
border-radius: 5px;
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
}
|
||||||
|
.info-label {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 14px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
}
|
||||||
|
.info-value {
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
background: rgba(255, 255, 255, 0.2);
|
||||||
|
padding: 8px 15px;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
.alert-box {
|
||||||
|
background-color: #fff3cd;
|
||||||
|
border-left: 4px solid #ffc107;
|
||||||
|
padding: 15px;
|
||||||
|
margin: 20px 0;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
.alert-box strong {
|
||||||
|
color: #856404;
|
||||||
|
}
|
||||||
|
.info-section {
|
||||||
|
background-color: #e8f4fd;
|
||||||
|
border-left: 4px solid #2196F3;
|
||||||
|
padding: 15px;
|
||||||
|
margin: 20px 0;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
.info-section p {
|
||||||
|
margin: 8px 0;
|
||||||
|
color: #0d47a1;
|
||||||
|
}
|
||||||
|
.link-button {
|
||||||
|
display: inline-block;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
color: white;
|
||||||
|
padding: 12px 30px;
|
||||||
|
text-decoration: none;
|
||||||
|
border-radius: 25px;
|
||||||
|
margin: 20px 0;
|
||||||
|
font-weight: 600;
|
||||||
|
transition: transform 0.2s;
|
||||||
|
}
|
||||||
|
.footer {
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
padding: 20px 30px;
|
||||||
|
text-align: center;
|
||||||
|
border-top: 1px solid #e0e0e0;
|
||||||
|
color: #666;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
.footer strong {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<p>Bonjour,</p>
|
<div class="email-container">
|
||||||
<p>Ci-dessous vous trouverez vos informations de connexion pour accéder à votre compte Teams :</p>
|
<div class="header">
|
||||||
<table style='border-collapse: collapse;'>
|
<h1>🔐 $titre</h1>
|
||||||
<tr>
|
</div>
|
||||||
<th style='border: 1px solid black; padding: 8px;'>Login</th>
|
<div class="content">
|
||||||
<th style='border: 1px solid black; padding: 8px;'>Mot de passe</th>
|
<p class="greeting">Bonjour,</p>
|
||||||
</tr>
|
<p>Nous avons le plaisir de vous transmettre vos identifiants de connexion pour accéder à votre espace Microsoft 365.</p>
|
||||||
<tr>
|
|
||||||
<td style='border: 1px solid black; padding: 8px;'>$login</td>
|
|
||||||
<td style='border: 1px solid black; padding: 8px;'>$password</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<p>Un changement du mot de passe vous sera demandé à la première connexion.</p>
|
<div class="info-box">
|
||||||
<p><b>Note:</b>Vous pouvez accéder à votre boite e-mail en vous rendant sur le site: https://www.office.com</p></br>
|
<div class="info-row">
|
||||||
<p>Veuillez conserver ces informations en lieu sûr.</p><br>
|
<span class="info-label">📧 Identifiant</span>
|
||||||
<p>Cordialement,<br>Service Informatique</p>
|
<span class="info-value">$login</span>
|
||||||
|
</div>
|
||||||
|
<div class="info-row">
|
||||||
|
<span class="info-label">🔑 Mot de passe</span>
|
||||||
|
<span class="info-value">$password</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="alert-box">
|
||||||
|
<strong>⚠️ Important :</strong> Pour votre sécurité, vous devrez modifier ce mot de passe lors de votre première connexion.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="info-section">
|
||||||
|
<p><strong>📱 Accès à vos services :</strong></p>
|
||||||
|
<p>• Messagerie Outlook</p>
|
||||||
|
<p>• Microsoft Teams</p>
|
||||||
|
<p>• OneDrive</p>
|
||||||
|
<p>• Office en ligne (Word, Excel, PowerPoint)</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<center>
|
||||||
|
<a href="https://www.office.com" class="link-button">🚀 Accéder à mon compte</a>
|
||||||
|
</center>
|
||||||
|
|
||||||
|
<p style="margin-top: 30px; font-size: 14px; color: #666;">
|
||||||
|
<strong>Conseil de sécurité :</strong> Conservez ces informations dans un endroit sûr et ne les partagez jamais avec quiconque.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="footer">
|
||||||
|
<p><strong>Service Informatique</strong></p>
|
||||||
|
<p>H3 Campus</p>
|
||||||
|
<p style="font-size: 12px; color: #999; margin-top: 10px;">Cet email a été envoyé automatiquement, merci de ne pas y répondre.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"@
|
"@
|
||||||
@@ -182,9 +330,91 @@ $mailMessage.IsBodyHtml = $true
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$smtpClient.Send($mailMessage)
|
$smtpClient.Send($mailMessage)
|
||||||
Write-Host "Email envoyé avec succès à $destinataire"
|
Write-Host "Email envoyé avec succès à $destinataire" -ForegroundColor Green
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host "Échec de l'envoi de l'email à $destinataire : $"
|
Write-Host "Échec de l'envoi de l'email à $destinataire : $_" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# NOUVELLE FONCTION : Attribuer toutes les licences cochées
|
||||||
|
function Attribuer-Licences {
|
||||||
|
param (
|
||||||
|
[string]$userId
|
||||||
|
)
|
||||||
|
|
||||||
|
try {
|
||||||
|
# Récupérer toutes les licences disponibles
|
||||||
|
$allLicenses = Get-MgSubscribedSku
|
||||||
|
|
||||||
|
# Définir les licences à attribuer
|
||||||
|
$licensesToAssign = @(
|
||||||
|
"EXCHANGESTANDARD_STUDENT", # Exchange Online (plan 1) pour les étudiants
|
||||||
|
"POWERAPPS_DEV", # Microsoft Power Apps for Developer
|
||||||
|
"STANDARDWOFFPACK_STUDENT" # Office 365 A1 pour les étudiants
|
||||||
|
)
|
||||||
|
|
||||||
|
$licenseIds = @()
|
||||||
|
|
||||||
|
foreach ($licenseName in $licensesToAssign) {
|
||||||
|
$license = $allLicenses | Where-Object { $_.SkuPartNumber -eq $licenseName }
|
||||||
|
if ($null -ne $license) {
|
||||||
|
$licenseIds += @{ SkuId = $license.SkuId }
|
||||||
|
Write-Host " ✓ Licence '$licenseName' trouvée" -ForegroundColor Green
|
||||||
|
} else {
|
||||||
|
Write-Host " ⚠ Licence '$licenseName' non disponible dans votre tenant" -ForegroundColor Yellow
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($licenseIds.Count -gt 0) {
|
||||||
|
Set-MgUserLicense -UserId $userId -AddLicenses $licenseIds -RemoveLicenses @()
|
||||||
|
Write-Host " ✓ $($licenseIds.Count) licence(s) attribuée(s) avec succès" -ForegroundColor Green
|
||||||
|
return $true
|
||||||
|
} else {
|
||||||
|
Write-Host " ✗ Aucune licence disponible à attribuer" -ForegroundColor Red
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch {
|
||||||
|
Write-Host " ✗ Erreur lors de l'attribution des licences : $_" -ForegroundColor Red
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Réinitialiser le mot de passe d'un utilisateur existant
|
||||||
|
function Reinitialiser-MotDePasse {
|
||||||
|
param (
|
||||||
|
[string]$email
|
||||||
|
)
|
||||||
|
|
||||||
|
try {
|
||||||
|
$newPassword = Generer-MotDePasse
|
||||||
|
|
||||||
|
$PasswordProfile = @{
|
||||||
|
Password = $newPassword
|
||||||
|
ForceChangePasswordNextSignIn = $true
|
||||||
|
}
|
||||||
|
|
||||||
|
$existingUser = Get-MgUser -Filter "UserPrincipalName eq '$email'" -ErrorAction Stop
|
||||||
|
|
||||||
|
Update-MgUser -UserId $existingUser.Id -PasswordProfile $PasswordProfile
|
||||||
|
|
||||||
|
Write-Host " ✓ Mot de passe réinitialisé pour $email" -ForegroundColor Green
|
||||||
|
|
||||||
|
return @{
|
||||||
|
Success = $true
|
||||||
|
Email = $email
|
||||||
|
Password = $newPassword
|
||||||
|
IsReset = $true
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch {
|
||||||
|
Write-Host " ✗ Erreur lors de la réinitialisation du mot de passe : $_" -ForegroundColor Red
|
||||||
|
return @{
|
||||||
|
Success = $false
|
||||||
|
Email = $email
|
||||||
|
Password = $null
|
||||||
|
IsReset = $false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,6 +451,7 @@ Success = $true
|
|||||||
Email = $email
|
Email = $email
|
||||||
Password = $null
|
Password = $null
|
||||||
IsNewUser = $false
|
IsNewUser = $false
|
||||||
|
UserId = $existingUser.Id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,30 +467,36 @@ $newUser = New-MgUser -DisplayName "$prenom $nom" `
|
|||||||
-UsageLocation $usageLocation
|
-UsageLocation $usageLocation
|
||||||
|
|
||||||
if ($null -ne $newUser) {
|
if ($null -ne $newUser) {
|
||||||
$exchangeLicense = Get-MgSubscribedSku | Where-Object SkuPartNumber -eq 'EXCHANGESTANDARD_STUDENT'
|
Write-Host " ✓ Utilisateur créé avec succès" -ForegroundColor Green
|
||||||
|
Write-Host "Attribution des licences..." -ForegroundColor Yellow
|
||||||
|
|
||||||
if ($null -ne $exchangeLicense) {
|
# Attribuer toutes les licences
|
||||||
Set-MgUserLicense -UserId $newUser.Id `
|
$licenseSuccess = Attribuer-Licences -userId $newUser.Id
|
||||||
-AddLicenses @{SkuId = $exchangeLicense.SkuId} `
|
|
||||||
-RemoveLicenses @()
|
|
||||||
|
|
||||||
Write-Host "Licence Exchange Online for Students attribuée à $email" -ForegroundColor Green
|
|
||||||
|
|
||||||
|
if ($licenseSuccess) {
|
||||||
return @{
|
return @{
|
||||||
Success = $true
|
Success = $true
|
||||||
Email = $email
|
Email = $email
|
||||||
Password = $password
|
Password = $password
|
||||||
IsNewUser = $true
|
IsNewUser = $true
|
||||||
|
UserId = $newUser.Id
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Write-Host "Erreur : Licence Exchange Online for Students non trouvée" -ForegroundColor Red
|
Write-Host " ⚠ Utilisateur créé mais erreur lors de l'attribution des licences" -ForegroundColor Yellow
|
||||||
|
return @{
|
||||||
|
Success = $true
|
||||||
|
Email = $email
|
||||||
|
Password = $password
|
||||||
|
IsNewUser = $true
|
||||||
|
UserId = $newUser.Id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Write-Host "Erreur : L'utilisateur $email n'a pas pu être créé." -ForegroundColor Red
|
Write-Host " ✗ Erreur : L'utilisateur $email n'a pas pu être créé." -ForegroundColor Red
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host "Erreur lors de la création de l'utilisateur : $_" -ForegroundColor Red
|
Write-Host " ✗ Erreur lors de la création de l'utilisateur : $_" -ForegroundColor Red
|
||||||
}
|
}
|
||||||
|
|
||||||
return @{
|
return @{
|
||||||
@@ -267,43 +504,67 @@ Success = $false
|
|||||||
Email = $email
|
Email = $email
|
||||||
Password = $null
|
Password = $null
|
||||||
IsNewUser = $false
|
IsNewUser = $false
|
||||||
|
UserId = $null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# Parcourir chaque étudiant dans le fichier CSV et traiter
|
|
||||||
|
# BOUCLE PRINCIPALE MODIFIÉE
|
||||||
foreach ($etudiant in $etudiants) {
|
foreach ($etudiant in $etudiants) {
|
||||||
$prenom = $etudiant.Prenom
|
$prenom = $etudiant.Prenom
|
||||||
$nom = $etudiant.Nom
|
$nom = $etudiant.Nom
|
||||||
|
|
||||||
Write-Host "Traitement de l'étudiant : $prenom $nom" -ForegroundColor Cyan
|
Write-Host "`n========================================" -ForegroundColor Cyan
|
||||||
|
Write-Host "Traitement de l'étudiant : $prenom $nom" -ForegroundColor Cyan
|
||||||
|
Write-Host "========================================" -ForegroundColor Cyan
|
||||||
|
|
||||||
# Normaliser les chaînes et les convertir en minuscules
|
# Normaliser les chaînes et les convertir en minuscules
|
||||||
$prenomuser = (Normalize-String $prenom).ToLower()
|
$prenomuser = (Normalize-String $prenom).ToLower()
|
||||||
$nomuser = (Normalize-String $nom).ToLower()
|
$nomuser = (Normalize-String $nom).ToLower()
|
||||||
$domainuser = $domain.ToLower()
|
$domainuser = $domain.ToLower()
|
||||||
|
|
||||||
$Usermail = "$($prenomuser.substring(0,1)).$($nomuser)@$($domainuser)"
|
$Usermail = "$($prenomuser.substring(0,1)).$($nomuser)@$($domainuser)"
|
||||||
$AddressExist = Adresse-Existe $Usermail
|
$AddressExist = Adresse-Existe $Usermail
|
||||||
|
|
||||||
if ($AddressExist) {
|
if ($AddressExist) {
|
||||||
Write-Host "Adresse mail $Usermail existante !" -ForegroundColor Blue
|
Write-Host "Adresse mail $Usermail existante !" -ForegroundColor Blue
|
||||||
} else {
|
|
||||||
Write-Host "Création d'un nouvel utilisateur avec l'adresse $Usermail" -ForegroundColor Yellow
|
|
||||||
|
|
||||||
# Créer l'utilisateur dans Office 365
|
# Appliquer le comportement défini pour les comptes existants
|
||||||
$result = Creer-Utilisateur -prenom $prenom -nom $nom -email $Usermail -domain $domainuser
|
if ($ComportementComptesExistants -eq "ReinitializerMotDePasse") {
|
||||||
|
Write-Host "Réinitialisation du mot de passe en cours..." -ForegroundColor Yellow
|
||||||
|
$resetResult = Reinitialiser-MotDePasse -email $Usermail
|
||||||
|
|
||||||
# Vérifier si l'adresse a bien été créée
|
if ($resetResult.Success) {
|
||||||
if ($result.Success) {
|
# Envoyer un email avec le nouveau mot de passe
|
||||||
# Envoyer un email avec les informations de connexion
|
Envoyer-Email -destinataire $etudiant.Email -login $resetResult.Email -password $resetResult.Password -isReset $true
|
||||||
$messageEnvoi = Envoyer-Email -destinataire $etudiant.Email -login $result.Email -password $result.Password
|
Write-Host "E-mail de réinitialisation envoyé à $($etudiant.Email)" -ForegroundColor Green
|
||||||
Write-Host "E-mail envoyé à $($etudiant.Email) pour le compte $($result.Email)" -ForegroundColor Green
|
} else {
|
||||||
Write-Host $messageEnvoi -ForegroundColor Green
|
Write-Host "Échec de la réinitialisation du mot de passe pour $Usermail" -ForegroundColor Red
|
||||||
} else {
|
}
|
||||||
Write-Host "Erreur : Le compte $($result.Email) n'a pas été créé. Aucun e-mail envoyé." -ForegroundColor Red
|
} else {
|
||||||
}
|
Write-Host "Compte existant ignoré (aucune action effectuée)" -ForegroundColor Gray
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Write-Host "Création d'un nouvel utilisateur avec l'adresse $Usermail" -ForegroundColor Yellow
|
||||||
|
|
||||||
|
# Créer l'utilisateur dans Office 365
|
||||||
|
$result = Creer-Utilisateur -prenom $prenom -nom $nom -email $Usermail -domain $domainuser
|
||||||
|
|
||||||
|
# Vérifier si l'adresse a bien été créée
|
||||||
|
if ($result.Success) {
|
||||||
|
# Envoyer un email avec les informations de connexion
|
||||||
|
Envoyer-Email -destinataire $etudiant.Email -login $result.Email -password $result.Password
|
||||||
|
Write-Host "E-mail envoyé à $($etudiant.Email) pour le compte $($result.Email)" -ForegroundColor Green
|
||||||
|
} else {
|
||||||
|
Write-Host "Erreur : Le compte $($result.Email) n'a pas été créé. Aucun e-mail envoyé." -ForegroundColor Red
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Faire une pause de 10 secondes
|
# Faire une pause de 10 secondes
|
||||||
Write-Host "Pause de 10 secondes avant le traitement du prochain étudiant..." -ForegroundColor Gray
|
Write-Host "`nPause de 10 secondes avant le traitement du prochain étudiant..." -ForegroundColor Gray
|
||||||
Start-Sleep -Seconds 10
|
Start-Sleep -Seconds 10
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Write-Host "`n========================================" -ForegroundColor Green
|
||||||
|
Write-Host "Traitement terminé pour tous les étudiants" -ForegroundColor Green
|
||||||
|
Write-Host "========================================" -ForegroundColor Green
|
||||||
Reference in New Issue
Block a user