Get-aduser wird nicht richtig angezeigt
Hallo zusammen,
ich hoffe Ihr könnt mir helfen mein PowerShell Script zu verbessern, damit die Ausgabe richtig angezeigt wird.
KA wie ich das hingekommen soll:
Script cutoff--------------
ich hoffe Ihr könnt mir helfen mein PowerShell Script zu verbessern, damit die Ausgabe richtig angezeigt wird.
KA wie ich das hingekommen soll:
Script cutoff--------------
- Load ActiveDirectory module
- set Variable
- Die ersten beiden Befehle holen sich die .NET-Erweiterungen (sog. Assemblies) für die grafische Gestaltung in den RAM.
- Die nächste Zeile erstellt aus der Formsbibliothek das Fensterobjekt.
- Hintergrundfarbe für das Fenster festlegen
- Icon in die Titelleiste setzen
- $objForm.Icon="C:\Logos\XXX.jpg" #kann selbst definiert werden
- Hintergrundbild mit Formatierung Zentral = 2
- Position des Fensters festlegen
- Fenstergröße festlegen
- Titelleiste festlegen
- GLID's auslesen aus AD
<#
powered by US
#>
$GLID2 = Read-Host "Eingabe Global link ID"
'Programm wird ausgeführt bitte warten bis Eingabe erscheint.'
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$objForm.BackgroundImage = [System.Drawing.Image]::FromFile('C:\XXX\DEIN_LOGO) #kann selbst definiert werden
#User aus dem Ad anzeigen
$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(300,60)
$objLabel.Size = New-Object System.Drawing.Size(1000,20)
$objLabel.Text = "confirm GLID:"
$objForm.Controls.Add($objLabel)
$objCombobox = New-Object System.Windows.Forms.Combobox
$objCombobox.Location = New-Object System.Drawing.Size(300,80)
$objCombobox.Size = New-Object System.Drawing.Size(200,20)
$objCombobox.Height = 70
$objForm.Controls.Add($objCombobox)
$objForm.Topmost = $True
$objForm.Add_Shown({$objForm.Activate()})
$objCombobox.Items.AddRange($GLID2) #GLIDs werden aus der Variable geladen und angezeigt
$objCombobox.SelectedItem #ausgewählte GLID wird übernommen
$objCombobox.Add_SelectedIndexChanged({ })
#OK Button anzeigen lassen
$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Size(500,420)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = "OK"
$OKButton.Name = "OK"
#$OKButton.DialogResult = "OK" # Ansonsten wird Fenster geschlossen
$OKButton.Add_Click({$GLID2=Get-ADUser $GLID2 -Properties * | FL GivenName, Surname, Name, Created, Modified, CanonicalName, Enabled, LockedOut, LastLogonDate, PasswordLastSet, LastBadPasswordAttempt, PasswordNeverExpires, PasswordNotRequired, DisplayName, Description, Title, Office, OfficePhone, EmailAddress, HomeDirectory, HomeDrive, UserPrincipalName
[void] [Windows.Forms.MessageBox]::Show($GLID2)
})
$objForm.Controls.Add($OKButton)
#Abbrechen Button
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Size(600,420)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = "Abbrechen"
$CancelButton.Name = "Abbrechen"
$CancelButton.DialogResult = "Cancel"
$CancelButton.Add_Click({$objForm.Close()})
$objForm.Controls.Add($CancelButton)
[void] $objForm.ShowDialog()
Get-Module -Name Microsoft.PowerShell.Utility
cut-off-END---------
ich bekomme leider nicht die Werte die ich haben möchte
Pls Help, siehe Anhang für das Ergebnis wenn ich eine UserID eintrage.
Hoffe sehr Ihr könnt mir helfen!
Danke für jede konstruktive Kritik! :D
lieben Gruß
Please also mark the comments that contributed to the solution of the article
Content-Key: 585432
Url: https://administrator.de/contentid/585432
Printed on: April 20, 2024 at 00:04 o'clock
2 Comments
Latest comment
$GLID2=Get-ADUser $GLID2 -Properties * | FL GivenName, Surname, Name, Created, Modified, CanonicalName, Enabled, LockedOut, LastLogonDate, PasswordLastSet, LastBadPasswordAttempt, PasswordNeverExpires, PasswordNotRequired, DisplayName, Description, Title, Office, OfficePhone, EmailAddress, HomeDirectory, HomeDrive, UserPrincipalName | out-string
p.s. Bitte => Formatting instructions in the posts