Creation d'utilisateur

shellgirl Messages postés 3 Statut Membre -  
shellgirl Messages postés 3 Statut Membre -
bonjour.. je cherche à faire executer un script de création d'utilisateur avec Windows 7 que j'ai installé sur virtualbox j'ai aussi installé windows server 2008;activer toutes les fonctionnalités dans windows 7 que j'ai également mit dans mon domaine Active Directory. mais rien a faire j'ai toujours la même erreur: "l'appel de la méthode a échoué parce que system.string ne contient pas de méthode nommée 'isnullorwhitespace' ". aidez moi svp

3 réponses

  1. barnabe0057 Messages postés 14329 Date d'inscription   Statut Contributeur Dernière intervention   4 930
     
    Bonjour,

    Si tu fournissais le script ça serait peut-être plus simple de t'aider.
    0
  2. shellgirl Messages postés 3 Statut Membre
     
    Add-Type -AssemblyName System.Windows.Forms
    Add-Type -AssemblyName System.Drawing
    $hauteur=40

    $form = New-Object System.Windows.Forms.Form
    $form.Text = "Informations sur l'utilisateur à créer"
    $form.Size = New-Object System.Drawing.Size(700,500)
    $form.StartPosition = "CenterScreen"

    $OKButton = New-Object System.Windows.Forms.Button
    $OKButton.Location = New-Object System.Drawing.Point(250,400)
    $OKButton.Size = New-Object System.Drawing.Size(150,23)
    $OKButton.Text = "Créer utilisateur"
    $OKButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
    $form.AcceptButton = $OKButton
    $form.Controls.Add($OKButton)

    $CancelButton = New-Object System.Windows.Forms.Button
    $CancelButton.Location = New-Object System.Drawing.Point(420,400)
    $CancelButton.Size = New-Object System.Drawing.Size(75,23)
    $CancelButton.Text = "Annuler"
    $CancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
    $form.CancelButton = $CancelButton
    $form.Controls.Add($CancelButton)

    #ajouter le champ "Nom*"
    $label01 = New-Object System.Windows.Forms.Label
    $label01.Location = New-Object System.Drawing.Point(10,$hauteur)
    $label01.Size = New-Object System.Drawing.Size(200,20)
    $label01.Text = "Nom* : "
    $form.Controls.Add($label01)

    $textBox01 = New-Object System.Windows.Forms.TextBox
    $textBox01.Location = New-Object System.Drawing.Point(220,$hauteur)
    $textBox01.Size = New-Object System.Drawing.Size(300,20)
    $form.Controls.Add($textBox01)

    #ajouter le champ "Prénom"
    $hauteur=$hauteur+30
    $label02 = New-Object System.Windows.Forms.Label
    $label02.Location = New-Object System.Drawing.Point(10,$hauteur)
    $label02.Size = New-Object System.Drawing.Size(200,20)
    $label02.Text = "Prénom : "
    $form.Controls.Add($label02)

    $textBox02 = New-Object System.Windows.Forms.TextBox
    $textBox02.Location = New-Object System.Drawing.Point(220,$hauteur)
    $textBox02.Size = New-Object System.Drawing.Size(300,20)
    $form.Controls.Add($textBox02)

    #ajouter le champ "Nom complet"
    $hauteur=$hauteur+30
    $label02a = New-Object System.Windows.Forms.Label
    $label02a.Location = New-Object System.Drawing.Point(10,$hauteur)
    $label02a.Size = New-Object System.Drawing.Size(200,20)
    $label02a.Text = "Nom complet* : "
    $form.Controls.Add($label02a)

    $textBox02a = New-Object System.Windows.Forms.TextBox
    $textBox02a.Location = New-Object System.Drawing.Point(220,$hauteur)
    $textBox02a.Size = New-Object System.Drawing.Size(300,20)
    $form.Controls.Add($textBox02a)

    #ajouter le champs "Nom d'ouverture de session de l'utilisateur*"
    $hauteur=$hauteur+30
    $label07 = New-Object System.Windows.Forms.Label
    $label07.Location = New-Object System.Drawing.Point(10,$hauteur)
    $label07.Size = New-Object System.Drawing.Size(200,30)
    $label07.Text = "Nom d'ouverture de session de l'utilisateur* : "
    $form.Controls.Add($label07)

    $textBox07 = New-Object System.Windows.Forms.TextBox
    $textBox07.Location = New-Object System.Drawing.Point(220,$hauteur)
    $textBox07.Size = New-Object System.Drawing.Size(300,20)
    $form.Controls.Add($textBox07)

    #ajouter le champ "Fonction"
    $hauteur=$hauteur+40
    $label03 = New-Object System.Windows.Forms.Label
    $label03.Location = New-Object System.Drawing.Point(10,$hauteur)
    $label03.Size = New-Object System.Drawing.Size(200,20)
    $label03.Text = "Fonction : "
    $form.Controls.Add($label03)

    $textBox03 = New-Object System.Windows.Forms.TextBox
    $textBox03.Location = New-Object System.Drawing.Point(220,$hauteur)
    $textBox03.Size = New-Object System.Drawing.Size(300,20)
    $form.Controls.Add($textBox03)

    #ajouter le champs "Service"
    $hauteur=$hauteur+30
    $label09 = New-Object System.Windows.Forms.Label
    $label09.Location = New-Object System.Drawing.Point(10,$hauteur)
    $label09.Size = New-Object System.Drawing.Size(200,20)
    $label09.Text = "Service : "
    $form.Controls.Add($label09)

    $textBox09 = New-Object System.Windows.Forms.TextBox
    $textBox09.Location = New-Object System.Drawing.Point(220,$hauteur)
    $textBox09.Size = New-Object System.Drawing.Size(300,20)
    $form.Controls.Add($textBox09)

    #ajouter le champ "Numéro de téléphone"
    $hauteur=$hauteur+30
    $label04 = New-Object System.Windows.Forms.Label
    $label04.Location = New-Object System.Drawing.Point(10,$hauteur)
    $label04.Size = New-Object System.Drawing.Size(200,20)
    $label04.Text = "Numéro de téléphone : "
    $form.Controls.Add($label04)

    $textBox04 = New-Object System.Windows.Forms.TextBox
    $textBox04.Location = New-Object System.Drawing.Point(220,$hauteur)
    $textBox04.Size = New-Object System.Drawing.Size(300,20)
    $form.Controls.Add($textBox04)

    #ajouter le champs "Bureau"
    $hauteur=$hauteur+30
    $label05 = New-Object System.Windows.Forms.Label
    $label05.Location = New-Object System.Drawing.Point(10,$hauteur)
    $label05.Size = New-Object System.Drawing.Size(200,20)
    $label05.Text = "Bureau : "
    $form.Controls.Add($label05)

    $textBox05 = New-Object System.Windows.Forms.TextBox
    $textBox05.Location = New-Object System.Drawing.Point(220,$hauteur)
    $textBox05.Size = New-Object System.Drawing.Size(300,20)
    $form.Controls.Add($textBox05)

    #ajouter le champs "Date d'expiration"
    $hauteur=$hauteur+30
    $label06 = New-Object System.Windows.Forms.Label
    $label06.Location = New-Object System.Drawing.Point(10,$hauteur)
    $label06.Size = New-Object System.Drawing.Size(200,20)
    $label06.Text = "Date d'expiration : "
    $form.Controls.Add($label06)

    $textBox06 = New-Object System.Windows.Forms.DateTimePicker
    $textBox06.Location = New-Object System.Drawing.Point(220,$hauteur)
    $textBox06.Autosize
    $textBox06.ShowCheckBox = $True
    $textBox06.MinDate = Get-Date
    #$textBox06.Size = New-Object System.Drawing.Size(300,20)
    $form.Controls.Add($textBox06)

    #ajouter le champs "Copier les groupes de l'utilisateur:"
    $hauteur=$hauteur+30
    $label08 = New-Object System.Windows.Forms.Label
    $label08.Location = New-Object System.Drawing.Point(10,$hauteur)
    $label08.Size = New-Object System.Drawing.Size(200,20)
    $label08.Text = "Copier les groupes de l'utilisateur : "
    $form.Controls.Add($label08)

    $textBox08 = New-Object System.Windows.Forms.TextBox
    $textBox08.Location = New-Object System.Drawing.Point(220,$hauteur)
    $textBox08.Size = New-Object System.Drawing.Size(300,20)
    $form.Controls.Add($textBox08)

    #ajouter le champs "OU"
    $hauteur=$hauteur+30
    $label10 = New-Object System.Windows.Forms.Label
    $label10.Location = New-Object System.Drawing.Point(10,$hauteur)
    $label10.Size = New-Object System.Drawing.Size(200,20)
    $label10.Text = "UO où le user sera crée* : "
    $form.Controls.Add($label10)

    $textBox10 = New-Object System.Windows.Forms.ComboBox
    $textBox10.Location = New-Object System.Drawing.Point(220,$hauteur)
    $textBox10.Size = New-Object System.Drawing.Size(300,20)
    $textBox10.Items.Add("OU=People,OU=CM-TEST,DC=ALUSOC,DC=ORG")
    $textBox10.Items.Add("OU=People,OU=CM-Edea,DC=ALUSOC,DC=ORG")
    $textBox10.Items.Add("OU=People,OU=CM-Douala,DC=ALUSOC,DC=ORG")
    $textBox10.Sorted = $true
    $textBox10.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
    $form.Controls.Add($textBox10)

    $form.Topmost = $True
    $form.Add_Shown({$textBox01.Select()})
    $result = $form.ShowDialog()

    if ($result -eq [System.Windows.Forms.DialogResult]::OK)

    {

    # On teste si le nom est renseigné
    IF([string]::IsNullOrWhiteSpace($textBox01.Text)) {
    # IF(!$textBox01.Text) {
    $Popup=New-Object System.Windows.Forms.form
    $Popup.Size="400,120"
    $Popup.Text="Vérification des saisie"
    $popup.StartPosition="Centerscreen"
    $popup.Visible=$true
    $Label=New-Object System.Windows.Forms.Label
    $Label.Text="veuillez saisir le champs nom "
    $Label.Autosize="$True"
    $Label.Location="15,30"
    $Label.Font="arial,12"
    $Popup.controls.Add($Label)
    $Popup.Visible=$false
    $popup.showDialog()

    }

    Else {

    # On teste si le nom complet est renseigné
    IF([string]::IsNullOrWhiteSpace($textBox02a.Text)) {
    # IF(!$textBox02a.Text) {
    $Popup=New-Object System.Windows.Forms.form
    $Popup.Size="400,120"
    $Popup.Text="Vérification des saisie"
    $popup.StartPosition="Centerscreen"
    $popup.Visible=$true
    $Label=New-Object System.Windows.Forms.Label
    $Label.Text="veuillez saisir le champs nom complet "
    $Label.Autosize="$True"
    $Label.Location="15,30"
    $Label.Font="arial,12"
    $Popup.controls.Add($Label)
    $Popup.Visible=$false
    $popup.showDialog()

    }

    Else {

    # On teste si le Nom d'ouverture de session de l'utilisateur est renseigné
    IF([string]::IsNullOrWhiteSpace($textBox07.Text)) {
    # IF(!$textBox07.Text) {
    $Popup=New-Object System.Windows.Forms.form
    $Popup.Size="600,120"
    $Popup.Text="Vérification des saisie"
    $popup.StartPosition="Centerscreen"
    $popup.Visible=$true
    $Label=New-Object System.Windows.Forms.Label
    $Label.Text="veuillez saisir le champs Nom d'ouverture de session de l'utilisateur "
    $Label.Autosize="$True"
    $Label.Location="15,30"
    $Label.Font="arial,12"
    $Popup.controls.Add($Label)
    $Popup.Visible=$false
    $popup.showDialog()

    }

    Else {

    New-ADUser `
    -Name $textBox02a.Text `
    -GivenName $textBox01.Text `
    -SurName $textBox02.text `
    -DisplayName $textBox02a.Text `
    -sAMAccountName $textBox07.Text `
    -Path $textBox10.Text `
    -Title $textBox03.Text `
    -Department $TextBox09.Text `
    -OfficePhone $TextBox04.Text `
    -AccountExpirationDate $TextBox06.Value `
    -Office $TextBox05.Text `
    -UserPrincipalName $TextBox07.Text `
    -PassThru | Enable-ADAccount

    }
    }
    }

    }
    0
  3. shellgirl Messages postés 3 Statut Membre
     
    PLUS HAUT LE SCRIPT
    0