Meilleur auteur de réponses
script powershell creation/modification & supression compte AD et mail

Question
-
Bonjour,
je rencontre un problème et sollicite une aide.
je souhaite crée un script powershell qui fait l'ajout la modification et la suppression de compte ad est exchange avec un menu qui vous demande de faire un choix et bien sure les sécurité qui vont avec (vérification de compte avant creation)
merci d'avance
Réponses
-
bonjour,
j'ai fait ça est ca fonctionne comme je voulais après je pense quil peux etre mieux adapter
I
Import-Module ActiveDirectory
start-transcript -path ".\Creationlogs\log.log"
Import-Csv -Delimiter ";" C:\script\Creation-csv.csv | ForEach-Object {
$Identity = $_.'Matricule'
$Nom = $_.'Nom'
$Prenom = $_.'Prenom'
$title = $_.'Grade'+" "+$_.'Intitule_Grade'
$office = $_.'UF'+" "+$_.'Intitule_UF'
$Department = $_.'CR'+" "+$_.'Intitule_CR'
$Matricule = $_.'Matricule'
$Initials = $($Prenom.subString(0,1).ToLower())
$Initials = $($Prenom.subString(0,1).ToLower())
$TEMPUPN = $($Matricule.ToLower()+"@domain.fr")
$var = 'blabla'
New-Mailbox -Initials "$Initials" -UserPrincipalName "$TEMPUPN" -Name $_.'Matricule' -Alias $_.'Matricule' -LastName $_.'Nom' -FirstName $_.'Prenom' -OrganizationalUnit Outlook -Password (ConvertTo-SecureString 'MyPassword123' -AsPlainText -Force) -ResetPasswordOnNextLogon $True
Set-user -Identity "$Identity" -Department $Department -title "$title" -office "$office" -Company $_.'Intitule_Pole' -StateOrProvince $_.'Etablissement'
##Nom d'affichage ##
Set-User -Identity "$Identity" -DisplayName $($Nom.ToUpper()+ " " +$Prenom.ToUpper()+ " " +$var)
##UPN Nom.1er lettre du Prenom ##
Set-User -Identity "$Identity" -UserPrincipalName $($Nom.ToLower()+ "." + $Prenom.Substring(0,1).ToLower()+"@chu-nice.fr")}
Stop-Transcript
Stop-Transcript- Marqué comme réponse Rached Chader mardi 13 novembre 2018 10:10
Toutes les réponses
-
Bonjour,
les éléments sont un peu trop vague pour pouvoir fournir une réponse complète.
A partir des éléments indiqués, il ne s'agira pas d'un simple script Powershell, mais d'une "mini-application"
- avec affichage des choix
- affichage d'une liste de champs (à déterminer et saisir) pour la création, la modification, etc (appel d'une librairie système)
- Utilisation de RemotePowershell pour Exchange
A bientôt,
Thierry DEMAN. Exchange MVP. MCSE:Messaging 2013,MCSE:Server Infrastructure 2012(83 MCPs). MCSA Office 365 https://mvp.microsoft.com/en-us/mvp/Thierry%20Deman-7660 http://base.faqexchange.info
-
bonjour,
j'ai fait ça est ca fonctionne comme je voulais après je pense quil peux etre mieux adapter
I
Import-Module ActiveDirectory
start-transcript -path ".\Creationlogs\log.log"
Import-Csv -Delimiter ";" C:\script\Creation-csv.csv | ForEach-Object {
$Identity = $_.'Matricule'
$Nom = $_.'Nom'
$Prenom = $_.'Prenom'
$title = $_.'Grade'+" "+$_.'Intitule_Grade'
$office = $_.'UF'+" "+$_.'Intitule_UF'
$Department = $_.'CR'+" "+$_.'Intitule_CR'
$Matricule = $_.'Matricule'
$Initials = $($Prenom.subString(0,1).ToLower())
$Initials = $($Prenom.subString(0,1).ToLower())
$TEMPUPN = $($Matricule.ToLower()+"@domain.fr")
$var = 'blabla'
New-Mailbox -Initials "$Initials" -UserPrincipalName "$TEMPUPN" -Name $_.'Matricule' -Alias $_.'Matricule' -LastName $_.'Nom' -FirstName $_.'Prenom' -OrganizationalUnit Outlook -Password (ConvertTo-SecureString 'MyPassword123' -AsPlainText -Force) -ResetPasswordOnNextLogon $True
Set-user -Identity "$Identity" -Department $Department -title "$title" -office "$office" -Company $_.'Intitule_Pole' -StateOrProvince $_.'Etablissement'
##Nom d'affichage ##
Set-User -Identity "$Identity" -DisplayName $($Nom.ToUpper()+ " " +$Prenom.ToUpper()+ " " +$var)
##UPN Nom.1er lettre du Prenom ##
Set-User -Identity "$Identity" -UserPrincipalName $($Nom.ToLower()+ "." + $Prenom.Substring(0,1).ToLower()+"@chu-nice.fr")}
Stop-Transcript
Stop-Transcript- Marqué comme réponse Rached Chader mardi 13 novembre 2018 10:10