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

VBScript Discussion :

utilisateurs sous windows server


Sujet :

VBScript

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Femme Profil pro
    Étudiant
    Inscrit en
    Juillet 2011
    Messages
    78
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Juillet 2011
    Messages : 78
    Par défaut utilisateurs sous windows server
    Bonjour,
    J'ai le script suivante qui me donne les informations sur un utilisateur locale en msgbox ( sous windows server 2008) après entré le nom d'utilisateur.
    je voulais faire des modification sur cette script pour parcourir tout les utilisateur ( sans donner le nom d'un utilisateur après lance le script) , et mettre le résultat dans un fichier texte.

    Merci pour votre aide , je suis de niveau débutante en vbscript.
    le script est :

    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
     
     
    Option Explicit 
    On Error Resume Next 
    Dim User , LstNm , Acry , dlg , UserName, MSG ,Prop , result,domainname,newpass 
    domainname = InputBox("Please enter domain name: " & vbcrlf &      "If you leave it blank the domain name will be accepted as DOMAIN. " , "Domain Information") 
    if domainname = "" then domainname = "DOMAIN" 
    call main() 
    sub main() 
    UserName = InputBox("Please enter UserName: ", "User Information") 
    set User = GetObject("WinNT://" + domainname + "/" + UserName) 
    If User.Name = "" Then 
    Dim wu 
    wu = MsgBox("UserName is not specified." & vbcrlf & vbcrlf &      "Do you want to enter another name?",4,"No such user") 
    msgbox wu 
    if wu=6 then call main else exit sub 
    Else 
    MSG= vbCRLf 
    MSG = MSG &  "User (ID):    " & UserName & vbcrlf 
    MSG =  MSG & "Full Name:    " & User.FullName & vbcrlf 
    MSG =  MSG & "Description:    " & User.Description & vbcrlf 
    MSG = MSG  & vbcrlf 
    MSG = MSG & "Group Membership " & vbcrlf 
    For Each Prop In User.groups 
    MSG = MSG &  "                  " & Prop.Name  & vbcrlf 
    Next 'Prop 
    Acry = Instr(1, User.FullName, ", ", 1) 
    'LstNm = Left(User.FullName, Acry - 1) 
    If User.IsAccountLocked = -1 Then 
    MSG = MSG & vbcrlf 
    MSG = MSG & "Account Status:   Locked" & vbcrlf 
    Else 
    MSG = MSG & vbcrlf 
    MSG =  MSG & "Account Status:   Active" & vbcrlf 
    End if 
    'If User.LastLogin < 0 Then 
    'MSG = MSG & vbcrlf 
    'MSG =  MSG & LstNm & " is not logged on to domain." & vbcrlf 
    'Else 
    'MSG = MSG  & vbcrlf  
    'MSG =  MSG & LstNm & " Last" & vbCRLF & "User Logon" & vbCRLF &      "Time:       " & User.LastLogin & vbcrlf 
    'End if 
    If User.IsAccountLocked = -1 Then 
    MSG = MSG & vbcrlf 
    MSG = MSG & "Do you want to unlock " & vbcrlf 
    result=msgbox (msg,4,Username & " Status") 
    Else 
    MSG = MSG & vbcrlf 
    MSG =  MSG & "The user is not locked out." & vbcrlf 
    result=msgbox (msg,0,Username & " Status") 
    End if 
    if result=6 then 
    User.IsAccountLocked = 0 
    User.SetInfo 
    result = msgbox(username & " has been unlocked successfully.") 
    end if 
    result = msgbox (username & " Attempt to change the password of the user?",4,"Password") 
    if result = 6 then  
    newpass = InputBox(" Please enter the user's new password : ", "New Password") 
    Call User.SetPassword(NewPass) 
    result = msgbox (username & " The password has been changed successfully.",0,"Password change") 
    end if 
    result = msgbox (username & " user is allowed to change his/her password" &       vbcrlf & "at next logon?",4,"Authorization State") 
    if result = 6 then  
    User.passwordexpired = 1 
    User.SetInfo 
    result = msgbox (username & " will be able to change his/her password at next logon.",0,"Status Change") 
    end if 
    set User = nothing 
    set LstNm = nothing 
    set Acry = nothing 
    set wu = nothing 
    End If 
    wu = MsgBox("Do you want to enter another user name?",4,"New User") 
    if wu=6 then call main 
    end sub

  2. #2
    Membre émérite Avatar de cubitus91
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Mai 2004
    Messages
    726
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France

    Informations professionnelles :
    Activité : Consultant informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2004
    Messages : 726
    Par défaut
    hello,
    tu peux t'appuyer sur la class wmi :Win32_UserAccount
    voici un bout de code qui te retourne les infos:
    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
     
    On Error Resume Next 
     
    strComputer = "." 
    Set objWMIService = GetObject("winmgmts:" _ 
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
     
    Set colItems = objWMIService.ExecQuery _ 
        ("Select * from Win32_UserAccount Where LocalAccount = True") 
     
    For Each objItem in colItems 
        Wscript.Echo "Account Type: " & objItem.AccountType 
        Wscript.Echo "Caption: " & objItem.Caption 
        Wscript.Echo "Description: " & objItem.Description 
        Wscript.Echo "Disabled: " & objItem.Disabled 
        Wscript.Echo "Domain: " & objItem.Domain 
        Wscript.Echo "Full Name: " & objItem.FullName 
        Wscript.Echo "Local Account: " & objItem.LocalAccount 
        Wscript.Echo "Lockout: " & objItem.Lockout 
        Wscript.Echo "Name: " & objItem.Name 
        Wscript.Echo "Password Changeable: " & objItem.PasswordChangeable 
        Wscript.Echo "Password Expires: " & objItem.PasswordExpires 
        Wscript.Echo "Password Required: " & objItem.PasswordRequired 
        Wscript.Echo "SID: " & objItem.SID 
        Wscript.Echo "SID Type: " & objItem.SIDType 
        Wscript.Echo "Status: " & objItem.Status 
        Wscript.Echo
    Bonne soirée.

Discussions similaires

  1. [Batch] Créer utilisateurs sous Windows 2003 Server en Batch
    Par anthony0742 dans le forum Scripts/Batch
    Réponses: 5
    Dernier message: 26/05/2009, 11h46
  2. Pb sous Windows Server
    Par sld_info dans le forum Access
    Réponses: 1
    Dernier message: 29/05/2006, 21h31
  3. Outils d'administration vide sous Windows Server 2003
    Par FoxDeltaSierra dans le forum Windows Serveur
    Réponses: 3
    Dernier message: 30/11/2005, 09h32
  4. pb installation de sql server 2000 sous windows server 2003
    Par timsah dans le forum MS SQL Server
    Réponses: 5
    Dernier message: 02/10/2005, 14h06
  5. XP home sous Windows Server 2003
    Par beegees dans le forum Windows XP
    Réponses: 2
    Dernier message: 05/07/2005, 09h00

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