IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Windows Discussion :

Changement mot de passe administrateur local sur une machine du domaine


Sujet :

Windows

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre très actif
    Homme Profil pro
    etudiant
    Inscrit en
    Mai 2010
    Messages
    222
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Sénégal

    Informations professionnelles :
    Activité : etudiant

    Informations forums :
    Inscription : Mai 2010
    Messages : 222
    Par défaut Changement mot de passe administrateur local sur une machine du domaine
    Bonsoir ,
    J'ai ce script qui fonctionne sur une machine qui n'est pas dans un domaine mais que je l’exécute sur une machine dans un domaine elle ne marche pas . Ou dois je modifier pour qu'il puisse machine sur qui est dans un domaine . Merci bcp
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    '---------------------------------------------------------------------
    '
    '   The following script is to be used to create a local
    '   user account and add it to the local Administrators
    '   group. To use, change the strLocalUserName to the desired
    '   name and change strLocalPassword to the password for the account.
    '
    '   This script also will reset the password for the account if
    '   the account already exists and it will mark it as Hidden
    '   via a Registry key insertion.
    '
    '   Please note, there is a limitation with the NET USER command
    '   where you are unable to set an account as 'never expires'.
    '   The bottom part of the script works arounds this.
    '
    '---------------------------------------------------------------------
    
    Set objShell = CreateObject ("WScript.Shell")
    Set Shell = Nothing
    on error resume next
    
    '---------------------------------------------------------------------
    '         Create local account
    '---------------------------------------------------------------------
    Wscript.Echo "Managing Administrative User Account"
    
    Set oWshNet = CreateObject("WScript.Network")
    strComputer = oWshNet.ComputerName
    
    strLocalUserName = "testuser"
    strLocalPassword = "toto"
    strGroupname = "Administrateurs"
    Wscript.Echo "Variables Defined"
    
    WScript.Sleep(900)
    
    On Error Resume Next
    Set objUser = GetObject("WinNT://" & strComputer & "/" & strLocalUserName & ",user")
    If Err.Number <> 0 Then
    ' User account does not exist, create it.
    objShell.Run "NET USER "&strLocalUserName&" "&strLocalPassword&" /ADD " _
    & "/ACTIVE:YES /COMMENT:""iaatech"" /FULLNAME:" _
    & strLocalUserName &" /expires:never", 0, True
    Wscript.Echo "User Created"
    End If
    
    On Error Resume Next ' Try again
    Set objUser = GetObject("WinNT://" & strComputer & "/" & strLocalUserName & ",user")
    Wscript.Echo "User Exists"
    If Err.Number = 0 Then
    
    '---------------------------------------------------------------------
    ' Set New Password if user exists
    '---------------------------------------------------------------------
    objUser.SetPassword strLocalPassword
    objUser.SetInfo
    Wscript.Echo "Password Updated"
    
    '---------------------------------------------------------------------
    ' Connect to the group
    '---------------------------------------------------------------------
    Set objGroup = GetObject("WinNT://" & strComputer & "/" & strGroupname)
    
    '---------------------------------------------------------------------
    ' Add the user account to the group
    ' Uses error handling in case it is a member already
    '---------------------------------------------------------------------
    On Error Resume Next
    objGroup.Add(objUser.ADsPath)
    WScript.sleep 600
    objGroup.Add(objUser.ADsPath)
    ' Error -2147023518 is "The specified account name is already
    ' a member of the local group."
    Wscript.Echo "Account Added to Administrators Group"
    
    '---------------------------------------------------------------------
    ' Hide User Account
    '---------------------------------------------------------------------
    HKEY_LOCAL_MACHINE = &H80000002
    
    Set ObjRegistry = _
    GetObject("winmgmts:{impersonationLevel = impersonate}!\\" _
    & strComputer & "\root\default:StdRegProv")
    
    strPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList"
    
    Return = objRegistry.CreateKey(HKEY_LOCAL_MACHINE, strPath)
    
    Set oReg=GetObject( _
    "winmgmts:{impersonationLevel=impersonate}!\\" &_
    strComputer & "\root\default:StdRegProv")
    strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList"
    oReg.SetDWORDValue _
    HKEY_LOCAL_MACHINE,strKeyPath,strLocalUserName,0
    Wscript.Echo "Account Hidden"
    
    End If
    
    '---------------------------------------------------------------------
    '          Set Account password to never expire
    '       This is done externally due to NET USER limitations
    '---------------------------------------------------------------------
    Const ufDONT_EXPIRE_PASSWD = &H10000
    objUserFlags = objUser.Get("UserFlags")
    if (objUserFlags And ufDONT_EXPIRE_PASSWD) = 0 then
    objUserFlags = objUserFlags Or ufDONT_EXPIRE_PASSWD
    objUser.Put "UserFlags", objUserFlags
    objUser.SetInfo
    Wscript.Echo "Account Password set to never expire"
    end if

  2. #2
    Expert éminent
    Avatar de JML19
    Homme Profil pro
    Retraité : Electrotechnicien Electronicien Informaticien de la SNCF
    Inscrit en
    Décembre 2010
    Messages
    15 213
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Corrèze (Limousin)

    Informations professionnelles :
    Activité : Retraité : Electrotechnicien Electronicien Informaticien de la SNCF
    Secteur : Transports

    Informations forums :
    Inscription : Décembre 2010
    Messages : 15 213
    Billets dans le blog
    10
    Par défaut
    Bonsoir

    Je pense qu'il faut indiquer le domaine pour chaque utilisateur ou administrateur.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    strGroupname = "Administrateurs" je pense qu'il faut faire référence à l'administrateur du domaine ainsi de suite.
    Wscript.Echo "Variables Defined"
    Vous pouvez utiliser les FAQ (ICI) ou les Tutoriels (ICI) et aussi accéder au blog (ICI)

Discussions similaires

  1. mot de passe incorrect Paypal sur une boutique
    Par rodolphebrd dans le forum WordPress
    Réponses: 2
    Dernier message: 30/04/2014, 19h20
  2. Réponses: 5
    Dernier message: 09/03/2014, 17h13
  3. [WS 2003] Réinitialiser ou changer le mot de passe administrateur local
    Par azertix dans le forum Windows Serveur
    Réponses: 2
    Dernier message: 03/02/2014, 12h07
  4. j'ai oublié mon mot de passe administrateur local
    Par maikess dans le forum Windows Serveur
    Réponses: 10
    Dernier message: 07/07/2010, 18h22
  5. Mot de passe Administrateur local
    Par mazen_bn dans le forum Sécurité
    Réponses: 12
    Dernier message: 23/11/2006, 13h30

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo