Skip to content

Commit

Permalink
Renommage-de-groupesCSV-AD
Browse files Browse the repository at this point in the history
  • Loading branch information
runetsens authored Jan 23, 2025
1 parent 292d507 commit d4d5e9f
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions Ressources/Script/Renommage-de-groupesCSV-AD
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@

# Script 2 : Renommage d'un groupe

# Importer le module Active Directory
Import-Module ActiveDirectory
# Chemin du fichier log pour renommage
$logFilePathRenommage = "C:\Chemin\vers\logs_renommage_groupes.txt"

# Initialiser le fichier log
Add-Content -Path $logFilePathRenommage -Value "Début du renommage des groupes : $(Get-Date)`n"

# Demander le nom du groupe à modifier
$ancienNom = Read-Host "Entrez le nom du groupe à modifier"
$nouveauNom = Read-Host "Entrez le nouveau nom du groupe"

try {
Rename-ADObject -Identity (Get-ADGroup -Filter {Name -eq $ancienNom}).DistinguishedName -NewName $nouveauNom
Write-Host "Le groupe a été renommé de $ancienNom à $nouveauNom" -ForegroundColor Green
Add-Content -Path $logFilePathRenommage -Value "Le groupe $ancienNom a été renommé en $nouveauNom à $(Get-Date)`n"
} catch {
Write-Host ("Erreur lors du renommage du groupe {0} : {1}" -f $ancienNom, $_.Exception.Message) -ForegroundColor Red
Add-Content -Path $logFilePathRenommage -Value "Erreur lors du renommage du groupe $ancienNom : $($_.Exception.Message) à $(Get-Date)`n"
}

Add-Content -Path $logFilePathRenommage -Value "Renommage terminé : $(Get-Date)`n"
Write-Host "Renommage terminé." -ForegroundColor Cyan

# Importer le module Active Directory
Import-Module ActiveDirectory

Expand Down

0 comments on commit d4d5e9f

Please sign in to comment.