Question [Résolu] AD: Modifier suffixe tél et suppression 0

Plus d'informations
il y a 9 ans 9 mois #21919 par Glass
Bonjour a vous :)

Je dois modifier les numeros de tel en modifiant le 0 présent dans les numéros de tél par +33.

J'arrive à rajouter le +33 mais pour supprimer le 0 je ne vois pas. Quelqu'un aurait il un retour d'expérience ? Give thanks à vous.

Script:

[code:1]
# Verify how it looks like before executing the script.
# It's easy to add a Export-CSV at the end of this line to have a backup.
Get-ADUser -SearchBase \"OU=Test,DC=dreamhouse,DC=local\" -Filter * -properties *| select Name, telephoneNumber

# Add a \"+33\" infront of TelephoneNumber
Get-ADUser -SearchBase \"OU=Test,DC=dreamhouse,DC=local\" -Filter * -properties * |
ForEach-Object {
Set-ADObject -Identity $_.DistinguishedName -Replace @{telephoneNumber=\"+33$($_.telephoneNumber)\"}
}

# And Verify it went well.
Get-ADUser -SearchBase \"OU=Test,DC=dreamhouse,DC=local\" -Filter * -properties *| select Name, telephoneNumber, Pager
[/code:1]<br><br>Message édité par: Arnaud, à: 16/06/16 11:29

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 9 ans 9 mois #21921 par Laurent Dardenne
Salut,
ajoute le dans ta regex.

Tutoriels PowerShell

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 9 ans 9 mois #21922 par Glass
Bjr, Laurent

comment faire dans la regex? quel syntaxe?

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 9 ans 9 mois #21942 par Glass
Solution trouvée, je vous joins le script :)


[code:1]
# Verify how it looks like before executing the script.

# It's easy to add a Export-CSV at the end of this line to have a backup.

Get-ADUser -SearchBase \&quot;OU=Test,DC=dreamhouse,DC=local\&quot; -Filter * -properties *| select Name, telephoneNumber

# Add a \&quot;+33\&quot; infront of TelephoneNumber

Get-ADUser -SearchBase \&quot;OU=Test,DC=dreamhouse,DC=local\&quot; -Filter * -properties * |

ForEach-Object {

Set-ADObject -Identity $_.DistinguishedName -Replace @{telephoneNumber=\&quot;+33$($_.telephoneNumber.Substring(1))\&quot;}

}

# And Verify it went well.

Get-ADUser -SearchBase OU=Test,DC=dreamhouse,DC=local\&quot; -Filter * -properties *| select Name, telephoneNumber, Pager
[/code:1]<br><br>Message édité par: Arnaud, à: 16/06/16 11:27

Connexion ou Créer un compte pour participer à la conversation.

Temps de génération de la page : 0.043 secondes
Propulsé par Kunena