none
Script Power Shell Draw de imputBox outbox no AD RRS feed

  • Pergunta

  • Estou tentando fazer uma caixa personalizada que faça consulta de maquinas do AD, o mesmo que retorna os dados do comando <Get-ADComputer "N00000" | fl>. Meu objetivo é incrementar essa janela para realizar o inclusão, remoção, move e consultas de maquinas do AD. Comecei com a consulta que achei o mais simples mas ta complicado. Quem puder ajudar desde já muito obrigado.

    <

    Add-Type -AssemblyName System.Windows.Forms 

    $Form =New-Object system.Windows.Forms.Form
    $Form.Text="Get AD Computer"
    $Form.Size=New-Object System.Drawing.Size(660,640) 

    ############################################## Start functions

    $GetADComputer = {
    $host=$Inpulttext;
    $Getresult=
    Get-ADComputer {$InputBox = New-Object System.Windows.Forms.TextBox $InputBox.Location = New-Object System.Drawing.Size(20,50) $InputBox.Size = New-Object System.Drawing.Size(150,20)} | fl

    $InputBox.text = $Inpulttext
    $Form.Controls.Add($InputBox)
    $host | fl};
    $outputBox.text=$GetADComputer

    #################################################

    $InputBox = New-Object System.Windows.Forms.TextBox 
    $InputBox.Location = New-Object System.Drawing.Size(20,50) 
    $InputBox.Size = New-Object System.Drawing.Size(150,20) 
    $InputBox.text = $Inpulttext
    $Form.Controls.Add($InputBox)

    $outputBox = New-Object System.Windows.Forms.TextBox
    $outputBox.Location = New-Object System.Drawing.Size (10,150) 
    $outputBox.Size = New-Object System.Drawing.Size (565,200)
    $outputBox.MultiLine = $True
    $outputBox.ScrollBars = "Vertical"
    $Form.Controls.Add($outputBox)

    #################################################################
    $Button=New-Object System.Windows.Forms.Button 
    $Button.Location=New-Object System.Drawing.Size(400,30) 
    $Button.Size=New-Object System.Drawing.Size(110,80) 
    $Button.Text="Consulta" 
    $Button.Add_Click({$Getresult}) 
    $Form.Controls.Add($Button)

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

    ############################################## end buttons

    $Form.Add_Shown({$Form.Activate()})
    [void] $Form.ShowDialog()

    >

    quinta-feira, 13 de dezembro de 2018 21:33