CLS
$user = $null
$Target = $null
Import-Module ActiveDirectory
#Import-Module MSOnline
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")|out-null
[System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")|out-null
$MainForm = New-Object System.Windows.Forms.Form #Set the Main Frame
$MainForm.Text = "Users Info Viewer v2.0"
$MainForm.Size = New-Object System.Drawing.Size(1350,850)
$MainForm.StartPosition = "CenterScreen"
$MainForm.KeyPreview = $True
$MainForm.MaximizeBox = $false
$objLabel = New-Object System.Windows.Forms.Label #Set the Label
$objLabel.Location = New-Object System.Drawing.Size(0,52)
$objLabel.Size = New-Object System.Drawing.Size(60,15)
$objLabel.Text = "Search"
$MainForm.Controls.Add($objLabel)
############################################################################## Display Name
$LblDispalyname = New-Object System.Windows.Forms.Label #Set the Label
$LblDispalyname.Location = New-Object System.Drawing.Size(0,80)
$LblDispalyname.Size = New-Object System.Drawing.Size(90,15)
$LblDispalyname.Text = "Display Name"
$MainForm.Controls.Add($LblDispalyname)
$TxtDisplayname = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtDisplayname.Location = New-Object System.Drawing.Size(90,80)
$TxtDisplayname.Size = New-Object System.Drawing.Size(280,20)
$TxtDisplayname.Text = ""
$MainForm.Controls.Add($TxtDisplayname)
###############################################################################
############################################################################## UPN
$LblUPN = New-Object System.Windows.Forms.Label #Set the Label
$LblUPN.Location = New-Object System.Drawing.Size(0,110)
$LblUPN.Size = New-Object System.Drawing.Size(80,15)
$LblUPN.Text = "UPN"
$MainForm.Controls.Add($LblUPN)
$TxtUPN = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtUPN.Location = New-Object System.Drawing.Size(90,110)
$TxtUPN.Size = New-Object System.Drawing.Size(280,20)
$TxtUPN.Text = ""
$MainForm.Controls.Add($TxtUPN)
###############################################################################
############################################################################## Last Name
$LblLastName = New-Object System.Windows.Forms.Label #Set the Label
$LblLastName.Location = New-Object System.Drawing.Size(0,140)
$LblLastName.Size = New-Object System.Drawing.Size(80,15)
$LblLastName.Text = "Last Name"
$MainForm.Controls.Add($LblLastName)
$TxtLastName = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtLastName.Location = New-Object System.Drawing.Size(90,140)
$TxtLastName.Size = New-Object System.Drawing.Size(280,20)
$TxtLastName.Text = ""
$MainForm.Controls.Add($TxtLastName)
###############################################################################
############################################################################## First Name
$LblFirstName = New-Object System.Windows.Forms.Label #Set the Label
$LblFirstName.Location = New-Object System.Drawing.Size(0,170)
$LblFirstName.Size = New-Object System.Drawing.Size(80,15)
$LblFirstName.Text = "First Name"
$MainForm.Controls.Add($LblFirstName)
$TxtFirstName = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtFirstName.Location = New-Object System.Drawing.Size(90,170)
$TxtFirstName.Size = New-Object System.Drawing.Size(280,20)
$TxtFirstName.Text = ""
$MainForm.Controls.Add($TxtFirstName)
###############################################################################
############################################################################## Department
$LblDepartment = New-Object System.Windows.Forms.Label #Set the Label
$LblDepartment.Location = New-Object System.Drawing.Size(0,200)
$LblDepartment.Size = New-Object System.Drawing.Size(80,15)
$LblDepartment.Text = "Department"
$MainForm.Controls.Add($LblDepartment)
$TxtDepartment = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtDepartment.Location = New-Object System.Drawing.Size(90,200)
$TxtDepartment.Size = New-Object System.Drawing.Size(280,20)
$TxtDepartment.Text = ""
$MainForm.Controls.Add($TxtDepartment)
###############################################################################
############################################################################## City
$LblCity = New-Object System.Windows.Forms.Label #Set the Label
$LblCity.Location = New-Object System.Drawing.Size(0,230)
$LblCity.Size = New-Object System.Drawing.Size(80,15)
$LblCity.Text = "City"
$MainForm.Controls.Add($LblCity)
$TxtCity = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtCity.Location = New-Object System.Drawing.Size(90,230)
$TxtCity.Size = New-Object System.Drawing.Size(280,20)
$TxtCity.Text = ""
$MainForm.Controls.Add($TxtCity)
###############################################################################
############################################################################## LANID
$LblLANID = New-Object System.Windows.Forms.Label #Set the Label
$LblLANID.Location = New-Object System.Drawing.Size(0,260)
$LblLANID.Size = New-Object System.Drawing.Size(80,15)
$LblLANID.Text = "LAN ID"
$MainForm.Controls.Add($LblLANID)
$TxtLANID = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtLANID.Location = New-Object System.Drawing.Size(90,260)
$TxtLANID.Size = New-Object System.Drawing.Size(280,20)
$TxtLANID.Text = ""
$MainForm.Controls.Add($TxtLANID)
###############################################################################
############################################################################## Title
$LblTitle = New-Object System.Windows.Forms.Label #Set the Label
$LblTitle.Location = New-Object System.Drawing.Size(0,295)
$LblTitle.Size = New-Object System.Drawing.Size(80,15)
$LblTitle.Text = "Title"
$MainForm.Controls.Add($LblTitle)
$TxtTitle = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtTitle.Location = New-Object System.Drawing.Size(90,290)
$TxtTitle.Size = New-Object System.Drawing.Size(280,20)
$TxtTitle.Text = ""
$MainForm.Controls.Add($TxtTitle)
###############################################################################
############################################################################## O365
$LblO365 = New-Object System.Windows.Forms.Label #Set the Label
$LblO365.Location = New-Object System.Drawing.Size(0,325)
$LblO365.Size = New-Object System.Drawing.Size(80,15)
$LblO365.Text = "Office 365"
$MainForm.Controls.Add($LblO365)
$TxtO365 = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtO365.Location = New-Object System.Drawing.Size(90,320)
$TxtO365.Size = New-Object System.Drawing.Size(280,20)
$TxtO365.Text = ""
$MainForm.Controls.Add($TxtO365)
###############################################################################
############################################################################## Office Code
$LblOfficeCode = New-Object System.Windows.Forms.Label #Set the Label
$LblOfficeCode.Location = New-Object System.Drawing.Size(0,355)
$LblOfficeCode.Size = New-Object System.Drawing.Size(80,15)
$LblOfficeCode.Text = "Office Code"
$MainForm.Controls.Add($LblOfficeCode)
$TxtOfficeCode = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtOfficeCode.Location = New-Object System.Drawing.Size(90,350)
$TxtOfficeCode.Size = New-Object System.Drawing.Size(280,20)
$TxtOfficeCode.Text = ""
$MainForm.Controls.Add($TxtOfficeCode)
###############################################################################
############################################################################## Street Address
$LblStreetAddress = New-Object System.Windows.Forms.Label #Set the Label
$LblStreetAddress.Location = New-Object System.Drawing.Size(0,385)
$LblStreetAddress.Size = New-Object System.Drawing.Size(80,15)
$LblStreetAddress.Text = "Street Address"
$MainForm.Controls.Add($LblStreetAddress)
$TxtStreetAddress = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtStreetAddress.Location = New-Object System.Drawing.Size(90,380)
$TxtStreetAddress.Size = New-Object System.Drawing.Size(280,20)
$TxtStreetAddress.Text = ""
$MainForm.Controls.Add($TxtStreetAddress)
###############################################################################
############################################################################## Interal Exchange
$LblInteralExchange = New-Object System.Windows.Forms.Label #Set the Label
$LblInteralExchange.Location = New-Object System.Drawing.Size(0,415)
$LblInteralExchange.Size = New-Object System.Drawing.Size(80,15)
$LblInteralExchange.Text = "Exchange Srv"
$MainForm.Controls.Add($LblInteralExchange)
$TxtInteralExchange = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtInteralExchange.Location = New-Object System.Drawing.Size(90,410)
$TxtInteralExchange.Size = New-Object System.Drawing.Size(280,20)
$TxtInteralExchange.Text = ""
$MainForm.Controls.Add($TxtInteralExchange)
###############################################################################
############################################################################## Employee ID
$LblEmployeeID = New-Object System.Windows.Forms.Label #Set the Label
$LblEmployeeID.Location = New-Object System.Drawing.Size(0,445)
$LblEmployeeID.Size = New-Object System.Drawing.Size(80,15)
$LblEmployeeID.Text = "Employee ID"
$MainForm.Controls.Add($LblEmployeeID)
$TxtEmployeeID = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtEmployeeID.Location = New-Object System.Drawing.Size(90,440)
$TxtEmployeeID.Size = New-Object System.Drawing.Size(280,20)
$TxtEmployeeID.Text = ""
$MainForm.Controls.Add($TxtEmployeeID)
###############################################################################
############################################################################## Email Address
$LblEmaiAddress = New-Object System.Windows.Forms.Label #Set the Label
$LblEmaiAddress.Location = New-Object System.Drawing.Size(0,475)
$LblEmaiAddress.Size = New-Object System.Drawing.Size(80,15)
$LblEmaiAddress.Text = "Mail"
$MainForm.Controls.Add($LblEmaiAddress)
$TxtEmaiAddress = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtEmaiAddress.Location = New-Object System.Drawing.Size(90,470)
$TxtEmaiAddress.Size = New-Object System.Drawing.Size(280,20)
$TxtEmaiAddress.Text = ""
$MainForm.Controls.Add($TxtEmaiAddress)
###############################################################################
############################################################################## LyncSIP
$LblLyncSIP = New-Object System.Windows.Forms.Label #Set the Label
$LblLyncSIP.Location = New-Object System.Drawing.Size(0,505)
$LblLyncSIP.Size = New-Object System.Drawing.Size(80,15)
$LblLyncSIP.Text = "Lync SIP"
$MainForm.Controls.Add($LblLyncSIP)
$TxtLyncSIP = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtLyncSIP.Location = New-Object System.Drawing.Size(90,500)
$TxtLyncSIP.Size = New-Object System.Drawing.Size(280,20)
$TxtLyncSIP.Text = ""
$MainForm.Controls.Add($TxtLyncSIP)
###############################################################################
############################################################################## Telephone Number
$LblTelephoneNumber = New-Object System.Windows.Forms.Label #Set the Label
$LblTelephoneNumber.Location = New-Object System.Drawing.Size(0,535)
$LblTelephoneNumber.Size = New-Object System.Drawing.Size(80,15)
$LblTelephoneNumber.Text = "Telephone"
$MainForm.Controls.Add($LblTelephoneNumber)
$TxtTelephoneNumber = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtTelephoneNumber.Location = New-Object System.Drawing.Size(90,530)
$TxtTelephoneNumber.Size = New-Object System.Drawing.Size(280,20)
$TxtTelephoneNumber.Text = ""
$MainForm.Controls.Add($TxtTelephoneNumber)
###############################################################################
############################################################################## Country
$LblCountry = New-Object System.Windows.Forms.Label #Set the Label
$LblCountry.Location = New-Object System.Drawing.Size(0,565)
$LblCountry.Size = New-Object System.Drawing.Size(80,15)
$LblCountry.Text = "Country"
$MainForm.Controls.Add($LblCountry)
$TxtCountry = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtCountry.Location = New-Object System.Drawing.Size(90,560)
$TxtCountry.Size = New-Object System.Drawing.Size(280,20)
$TxtCountry.Text = ""
$MainForm.Controls.Add($TxtCountry)
###############################################################################
############################################################################## Description
$LblDescription = New-Object System.Windows.Forms.Label #Set the Label
$LblDescription.Location = New-Object System.Drawing.Size(0,595)
$LblDescription.Size = New-Object System.Drawing.Size(80,15)
$LblDescription.Text = "Description"
$MainForm.Controls.Add($LblDescription)
$TxtDescription = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtDescription.Location = New-Object System.Drawing.Size(90,590)
$TxtDescription.Size = New-Object System.Drawing.Size(280,20)
$TxtDescription.Text = ""
$MainForm.Controls.Add($TxtDescription)
###############################################################################
############################################################################## Manager
$LblManager = New-Object System.Windows.Forms.Label #Set the Label
$LblManager.Location = New-Object System.Drawing.Size(0,625)
$LblManager.Size = New-Object System.Drawing.Size(80,15)
$LblManager.Text = "Manager"
$MainForm.Controls.Add($LblManager)
$TxtManager = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtManager.Location = New-Object System.Drawing.Size(90,620)
$TxtManager.Size = New-Object System.Drawing.Size(280,20)
$TxtManager.Text = ""
$MainForm.Controls.Add($TxtManager)
###############################################################################
############################################################################## pwdLastSetDateTime
$LblpwdLastSetDateTime = New-Object System.Windows.Forms.Label #Set the Label
$LblpwdLastSetDateTime.Location = New-Object System.Drawing.Size(400,25)
$LblpwdLastSetDateTime.Size = New-Object System.Drawing.Size(180,15)
$LblpwdLastSetDateTime.Text = "Password Last Set Time"
$MainForm.Controls.Add($LblpwdLastSetDateTime)
$TxtpwdLastSetDateTime = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtpwdLastSetDateTime.Location = New-Object System.Drawing.Size(590,20)
$TxtpwdLastSetDateTime.Size = New-Object System.Drawing.Size(280,20)
$TxtpwdLastSetDateTime.Text = ""
$MainForm.Controls.Add($TxtpwdLastSetDateTime)
###############################################################################
############################################################################## Bad Password Time
$LblpwdBadPasswordTime = New-Object System.Windows.Forms.Label #Set the Label
$LblpwdBadPasswordTime.Location = New-Object System.Drawing.Size(400,55)
$LblpwdBadPasswordTime.Size = New-Object System.Drawing.Size(180,15)
$LblpwdBadPasswordTime.Text = "Bad Password Time"
$MainForm.Controls.Add($LblpwdBadPasswordTime)
$TxtBadPasswordTime = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtBadPasswordTime.Location = New-Object System.Drawing.Size(590,50)
$TxtBadPasswordTime.Size = New-Object System.Drawing.Size(280,20)
$TxtBadPasswordTime.Text = ""
$MainForm.Controls.Add($TxtBadPasswordTime)
###############################################################################
############################################################################## Last Logon Time
$LblLastLogonTime = New-Object System.Windows.Forms.Label #Set the Label
$LblLastLogonTime.Location = New-Object System.Drawing.Size(400,85)
$LblLastLogonTime.Size = New-Object System.Drawing.Size(180,15)
$LblLastLogonTime.Text = "Last Logon Time"
$MainForm.Controls.Add($LblLastLogonTime)
$TxtLastLogonTime = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtLastLogonTime.Location = New-Object System.Drawing.Size(590,80)
$TxtLastLogonTime.Size = New-Object System.Drawing.Size(280,20)
$TxtLastLogonTime.Text = ""
$MainForm.Controls.Add($TxtLastLogonTime)
###############################################################################
############################################################################## Password Expires Time
$LblPasswordExpiresime = New-Object System.Windows.Forms.Label #Set the Label
$LblPasswordExpiresime.Location = New-Object System.Drawing.Size(400,115)
$LblPasswordExpiresime.Size = New-Object System.Drawing.Size(180,15)
$LblPasswordExpiresime.Text = "Password Expires Time"
$MainForm.Controls.Add($LblPasswordExpiresime)
$TxtPasswordExpiresime = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtPasswordExpiresime.Location = New-Object System.Drawing.Size(590,110)
$TxtPasswordExpiresime.Size = New-Object System.Drawing.Size(280,20)
$TxtPasswordExpiresime.Text = ""
$MainForm.Controls.Add($TxtPasswordExpiresime)
###############################################################################
############################################################################## Account Created At
$LblAccountCreatedAt = New-Object System.Windows.Forms.Label #Set the Label
$LblAccountCreatedAt.Location = New-Object System.Drawing.Size(400,145)
$LblAccountCreatedAt.Size = New-Object System.Drawing.Size(180,15)
$LblAccountCreatedAt.Text = "Account OU"
$MainForm.Controls.Add($LblAccountCreatedAt)
$TxtAccountCreatedAt = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtAccountCreatedAt.Location = New-Object System.Drawing.Size(590,140)
$TxtAccountCreatedAt.Size = New-Object System.Drawing.Size(280,20)
$TxtAccountCreatedAt.Text = ""
$MainForm.Controls.Add($TxtAccountCreatedAt)
###############################################################################
############################################################################## whenCreated
$LblwhenCreated = New-Object System.Windows.Forms.Label #Set the Label
$LblwhenCreated.Location = New-Object System.Drawing.Size(400,175)
$LblwhenCreated.Size = New-Object System.Drawing.Size(180,15)
$LblwhenCreated.Text = "Account Created Time"
$MainForm.Controls.Add($LblwhenCreated)
$TxtwhenCreated = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtwhenCreated.Location = New-Object System.Drawing.Size(590,170)
$TxtwhenCreated.Size = New-Object System.Drawing.Size(280,20)
$TxtwhenCreated.Text = ""
$MainForm.Controls.Add($TxtwhenCreated)
###############################################################################
############################################################################## whenChanged
$LblwhenChanged = New-Object System.Windows.Forms.Label #Set the Label
$LblwhenChanged.Location = New-Object System.Drawing.Size(400,205)
$LblwhenChanged.Size = New-Object System.Drawing.Size(180,15)
$LblwhenChanged.Text = "Account When Changed"
$MainForm.Controls.Add($LblwhenChanged)
$TxtwhenChanged = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtwhenChanged.Location = New-Object System.Drawing.Size(590,200)
$TxtwhenChanged.Size = New-Object System.Drawing.Size(280,20)
$TxtwhenChanged.Text = ""
$MainForm.Controls.Add($TxtwhenChanged)
###############################################################################
############################################################################## PasswordNeverExpires
$LblPasswordNeverExpires = New-Object System.Windows.Forms.Label #Set the Label
$LblPasswordNeverExpires.Location = New-Object System.Drawing.Size(400,235)
$LblPasswordNeverExpires.Size = New-Object System.Drawing.Size(180,15)
$LblPasswordNeverExpires.Text = "Password Never Expires"
$MainForm.Controls.Add($LblPasswordNeverExpires)
$TxtPasswordNeverExpires = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtPasswordNeverExpires.Location = New-Object System.Drawing.Size(590,230)
$TxtPasswordNeverExpires.Size = New-Object System.Drawing.Size(280,20)
$TxtPasswordNeverExpires.Text = ""
$MainForm.Controls.Add($TxtPasswordNeverExpires)
###############################################################################
############################################################################## Lockedout
$LblLockedout = New-Object System.Windows.Forms.Label #Set the Label
$LblLockedout.Location = New-Object System.Drawing.Size(400,265)
$LblLockedout.Size = New-Object System.Drawing.Size(180,15)
$LblLockedout.Text = "Account Locked Out"
$MainForm.Controls.Add($LblLockedout)
$TxtLockedout = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtLockedout.Location = New-Object System.Drawing.Size(590,260)
$TxtLockedout.Size = New-Object System.Drawing.Size(280,20)
$TxtLockedout.Text = ""
$MainForm.Controls.Add($TxtLockedout)
###############################################################################
############################################################################## badpwdcount
$Lblbadpwdcount = New-Object System.Windows.Forms.Label #Set the Label
$Lblbadpwdcount.Location = New-Object System.Drawing.Size(400,295)
$Lblbadpwdcount.Size = New-Object System.Drawing.Size(180,15)
$Lblbadpwdcount.Text = "Bad Password Count"
$MainForm.Controls.Add($Lblbadpwdcount)
$Txtbadpwdcount = New-Object System.Windows.Forms.textbox #Set the Text Field
$Txtbadpwdcount.Location = New-Object System.Drawing.Size(590,290)
$Txtbadpwdcount.Size = New-Object System.Drawing.Size(280,20)
$Txtbadpwdcount.Text = ""
$MainForm.Controls.Add($Txtbadpwdcount)
###############################################################################
############################################################################## accountExpires
$LblaccountExpires = New-Object System.Windows.Forms.Label #Set the Label
$LblaccountExpires.Location = New-Object System.Drawing.Size(400,325)
$LblaccountExpires.Size = New-Object System.Drawing.Size(180,15)
$LblaccountExpires.Text = "Account Expires Time"
$MainForm.Controls.Add($LblaccountExpires)
$TxtaccountExpires = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtaccountExpires.Location = New-Object System.Drawing.Size(590,320)
$TxtaccountExpires.Size = New-Object System.Drawing.Size(280,20)
$TxtaccountExpires.Text = ""
$MainForm.Controls.Add($TxtaccountExpires)
###############################################################################
############################################################################## memberof
$Lblmemberof = New-Object System.Windows.Forms.Label #Set the Label
$Lblmemberof.Location = New-Object System.Drawing.Size(400,355)
$Lblmemberof.Size = New-Object System.Drawing.Size(180,15)
$Lblmemberof.Text = "User In following Groups"
$MainForm.Controls.Add($Lblmemberof)
$Txtmemberof = New-Object System.Windows.Forms.richtextbox #Set the Text Field
$Txtmemberof.Location = New-Object System.Drawing.Size(400,385)
$Txtmemberof.Size = New-Object System.Drawing.Size(900,300)
$Txtmemberof.Text = ""
$MainForm.Controls.Add($Txtmemberof)
###############################################################################
########################################################################################## Keyword input Box
$TxtField = New-Object System.Windows.Forms.textbox #Set the Text Field
$TxtField.Location = New-Object System.Drawing.Size(90,20)
$TxtField.Size = New-Object System.Drawing.Size(280,20)
$TxtField.Text = ""
$TxtField.add_TextChanged({
$TxtDisplayname.Text = $null
$TxtUPN.Text = $null
$TxtLastName.Text = $null
$TxtFirstName.Text = $null
$TxtDepartment.Text = $null
$TxtCity.Text = $null
$TxtLANID.Text = $null
$TxtTitle.Text = $null
$TxtO365.Text = $null
$TxtOfficeCode.Text = $null
$TxtStreetAddress.Text = $null
$TxtInteralExchange.Text = $null
$TxtEmployeeID.Text = $null
$TxtEmaiAddress.Text = $null
$TxtLyncSIP.Text = $null
$TxtTelephoneNumber.Text = $null
$TxtCountry.Text = $null
$TxtDescription.Text = $null
$TxtManager.Text = $null
$TxtpwdLastSetDateTime.Text = $null
$TxtBadPasswordTime.Text = $null
$TxtLastLogonTime.Text = $null
$TxtPasswordExpiresime.Text = $null
$TxtAccountCreatedAt.Text = $null
$TxtwhenCreated.Text = $null
$TxtwhenChanged.Text = $null
$TxtPasswordNeverExpires.Text = $null
$TxtLockedout.Text = $null
$Txtbadpwdcount.Text = $null
$Txtmemberof.Text = $null
$TxtaccountExpires.Text = $null
$user = $null
$Target = $null
#$TxtField.Text= $null
$pwdLastSetDateTime = $null
$badPasswordTimeDateTime = $null
$lastLogonDateTime = $null
$pwdNextExpireDateTime = $null
#$lastLogonDateTime = $null
$whenCreated = $null
$whenChanged = $null
$AccountExpiresTime = $null
$PasswordNeverExpires = $null
$lockedout = $null
$badpwdcount = $null
$mail = $null
$c = $null
$city = $null
$country = $null
$department = $null
$Description = $null
$manager = $null
$memberof = $null
$DistinguishedName = $null
$userPrincipalName = $null
$employeeID = $null
$givenname = $null
$targetAddress = $null
$title = $null
$sn = $null
$LyncSIP = $null
$sAMAccountName = $null
$displayName = $null
$physicalDeliveryOfficeName = $null
$msExchHomeServerName = $null
$streetAddress = $null
$telephoneNumber = $null
})
$MainForm.Controls.Add($TxtField)
###########################################################################################
$RadioBoxDisplayName = New-Object System.Windows.Forms.radiobutton #Set the Radiobutton
$RadioBoxDisplayName.Location = New-Object System.Drawing.Size(85,50)
$RadioBoxDisplayName.Size = New-Object System.Drawing.Size(110,20)
$RadioBoxDisplayName.Text = "Display Name"
$RadioBoxDisplayName.add_Click({
$TxtDisplayname.Text = $null
$TxtUPN.Text = $null
$TxtLastName.Text = $null
$TxtFirstName.Text = $null
$TxtDepartment.Text = $null
$TxtCity.Text = $null
$TxtLANID.Text = $null
$TxtTitle.Text = $null
$TxtO365.Text = $null
$TxtOfficeCode.Text = $null
$TxtStreetAddress.Text = $null
$TxtInteralExchange.Text = $null
$TxtEmployeeID.Text = $null
$TxtEmaiAddress.Text = $null
$TxtLyncSIP.Text = $null
$TxtTelephoneNumber.Text = $null
$TxtCountry.Text = $null
$TxtDescription.Text = $null
$TxtManager.Text = $null
$TxtpwdLastSetDateTime.Text = $null
$TxtBadPasswordTime.Text = $null
$TxtLastLogonTime.Text = $null
$TxtPasswordExpiresime.Text = $null
$TxtAccountCreatedAt.Text = $null
$TxtwhenCreated.Text = $null
$TxtwhenChanged.Text = $null
$TxtPasswordNeverExpires.Text = $null
$TxtLockedout.Text = $null
$Txtbadpwdcount.Text = $null
$Txtmemberof.Text = $null
$TxtaccountExpires.Text = $null
$user = $null
$Target = $null
$TxtField.Text= $null
$pwdLastSetDateTime = $null
$badPasswordTimeDateTime = $null
$lastLogonDateTime = $null
$pwdNextExpireDateTime = $null
#$lastLogonDateTime = $null
$whenCreated = $null
$whenChanged = $null
$AccountExpiresTime = $null
$PasswordNeverExpires = $null
$lockedout = $null
$badpwdcount = $null
$mail = $null
$c = $null
$city = $null
$country = $null
$department = $null
$Description = $null
$manager = $null
$memberof = $null
$DistinguishedName = $null
$userPrincipalName = $null
$employeeID = $null
$givenname = $null
$targetAddress = $null
$title = $null
$sn = $null
$LyncSIP = $null
$sAMAccountName = $null
$displayName = $null
$physicalDeliveryOfficeName = $null
$msExchHomeServerName = $null
$streetAddress = $null
$telephoneNumber = $null
} )
$MainForm.Controls.Add($RadioBoxDisplayName)
$RadioBoxLANID = New-Object System.Windows.Forms.radiobutton #Set the Radiobutton
$RadioBoxLANID.Location = New-Object System.Drawing.Size(200,50)
$RadioBoxLANID.Size = New-Object System.Drawing.Size(90,20)
$RadioBoxLANID.Text = "LAN ID"
$RadioBoxLANID.Checked = $true
$RadioBoxLANID.add_Click({
$TxtDisplayname.Text = $null
$TxtUPN.Text = $null
$TxtLastName.Text = $null
$TxtFirstName.Text = $null
$TxtDepartment.Text = $null
$TxtCity.Text = $null
$TxtLANID.Text = $null
$TxtTitle.Text = $null
$TxtO365.Text = $null
$TxtOfficeCode.Text = $null
$TxtStreetAddress.Text = $null
$TxtInteralExchange.Text = $null
$TxtEmployeeID.Text = $null
$TxtEmaiAddress.Text = $null
$TxtLyncSIP.Text = $null
$TxtTelephoneNumber.Text = $null
$TxtCountry.Text = $null
$TxtDescription.Text = $null
$TxtManager.Text = $null
$TxtpwdLastSetDateTime.Text = $null
$TxtBadPasswordTime.Text = $null
$TxtLastLogonTime.Text = $null
$TxtPasswordExpiresime.Text = $null
$TxtAccountCreatedAt.Text = $null
$TxtwhenCreated.Text = $null
$TxtwhenChanged.Text = $null
$TxtPasswordNeverExpires.Text = $null
$TxtLockedout.Text = $null
$Txtbadpwdcount.Text = $null
$Txtmemberof.Text = $null
$TxtaccountExpires.Text = $null
$user = $null
$Target = $null
$TxtField.Text= $null
$pwdLastSetDateTime = $null
$badPasswordTimeDateTime = $null
$lastLogonDateTime = $null
$pwdNextExpireDateTime = $null
#$lastLogonDateTime = $null
$whenCreated = $null
$whenChanged = $null
$AccountExpiresTime = $null
$PasswordNeverExpires = $null
$lockedout = $null
$badpwdcount = $null
$mail = $null
$c = $null
$city = $null
$country = $null
$department = $null
$Description = $null
$manager = $null
$memberof = $null
$DistinguishedName = $null
$userPrincipalName = $null
$employeeID = $null
$givenname = $null
$targetAddress = $null
$title = $null
$sn = $null
$LyncSIP = $null
$sAMAccountName = $null
$displayName = $null
$physicalDeliveryOfficeName = $null
$msExchHomeServerName = $null
$streetAddress = $null
$telephoneNumber = $null
} )
$MainForm.Controls.Add($RadioBoxLANID)
$RadioBoxEmail = New-Object System.Windows.Forms.radiobutton #Set the Radiobutton
$RadioBoxEmail.Location = New-Object System.Drawing.Size(290,50)
$RadioBoxEmail.Size = New-Object System.Drawing.Size(90,20)
$RadioBoxEmail.Text = "Mail Address"
$RadioBoxEmail.add_Click({
$TxtDisplayname.Text = $null
$TxtUPN.Text = $null
$TxtLastName.Text = $null
$TxtFirstName.Text = $null
$TxtDepartment.Text = $null
$TxtCity.Text = $null
$TxtLANID.Text = $null
$TxtTitle.Text = $null
$TxtO365.Text = $null
$TxtOfficeCode.Text = $null
$TxtStreetAddress.Text = $null
$TxtInteralExchange.Text = $null
$TxtEmployeeID.Text = $null
$TxtEmaiAddress.Text = $null
$TxtLyncSIP.Text = $null
$TxtTelephoneNumber.Text = $null
$TxtCountry.Text = $null
$TxtDescription.Text = $null
$TxtManager.Text = $null
$TxtpwdLastSetDateTime.Text = $null
$TxtBadPasswordTime.Text = $null
$TxtLastLogonTime.Text = $null
$TxtPasswordExpiresime.Text = $null
$TxtAccountCreatedAt.Text = $null
$TxtwhenCreated.Text = $null
$TxtwhenChanged.Text = $null
$TxtPasswordNeverExpires.Text = $null
$TxtLockedout.Text = $null
$Txtbadpwdcount.Text = $null
$Txtmemberof.Text = $null
$TxtaccountExpires.Text = $null
$user = $null
$Target = $null
$TxtField.Text= $null
$pwdLastSetDateTime = $null
$badPasswordTimeDateTime = $null
$lastLogonDateTime = $null
$pwdNextExpireDateTime = $null
#$lastLogonDateTime = $null
$whenCreated = $null
$whenChanged = $null
$AccountExpiresTime = $null
$PasswordNeverExpires = $null
$lockedout = $null
$badpwdcount = $null
$mail = $null
$c = $null
$city = $null
$country = $null
$department = $null
$Description = $null
$manager = $null
$memberof = $null
$DistinguishedName = $null
$userPrincipalName = $null
$employeeID = $null
$givenname = $null
$targetAddress = $null
$title = $null
$sn = $null
$LyncSIP = $null
$sAMAccountName = $null
$displayName = $null
$physicalDeliveryOfficeName = $null
$msExchHomeServerName = $null
$streetAddress = $null
$telephoneNumber = $null
} )
$MainForm.Controls.Add($RadioBoxEmail)
$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Size(700,750)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = "OK"
$OKButton.Add_Click(
{
if($RadioBoxDisplayName.Checked -eq $true )
{
$DisplayName = $TxtField.Text
$user = Get-ADUser -Filter {CN -eq $DisplayName} -Properties cn, LockedOut, pwdLastSet, `
badPwdCount, badPasswordTime, lastLogon, lastLogoff, lastLogonTimeStamp, `
whenCreated, whenChanged,PasswordNeverExpires,mail,c,city,country,department,Description,manager,memberof,`
DistinguishedName,employeeID,givenname,targetAddress,title,sn,msRTCSIP-PrimaryUserAddress,sAMAccountName,`
displayName,userPrincipalName,physicalDeliveryOfficeName,msExchHomeServerName,streetAddress,telephoneNumber,accountExpires
}
if($RadioBoxLANID.Checked -eq $true )
{
$LANID = $TxtField.Text
$user = Get-ADUser $LANID -Properties cn, LockedOut, pwdLastSet, `
badPwdCount, badPasswordTime, lastLogon, lastLogoff, lastLogonTimeStamp, `
whenCreated, whenChanged,PasswordNeverExpires,mail,c,city,country,department,Description,manager,memberof,`
DistinguishedName,employeeID,givenname,targetAddress,title,sn,msRTCSIP-PrimaryUserAddress,sAMAccountName,`
displayName,userPrincipalName,physicalDeliveryOfficeName,msExchHomeServerName,streetAddress,telephoneNumber,accountExpires
}
if($RadioBoxEmail.Checked -eq $true )
{
$Mail = $TxtField.Text
$user = Get-ADUser -Filter {mail -eq $Mail} -Properties cn, LockedOut, pwdLastSet, `
badPwdCount, badPasswordTime, lastLogon, lastLogoff, lastLogonTimeStamp, `
whenCreated, whenChanged,PasswordNeverExpires,mail,c,city,country,department,Description,manager,memberof,`
DistinguishedName,employeeID,givenname,targetAddress,title,sn,msRTCSIP-PrimaryUserAddress,sAMAccountName,`
displayName,userPrincipalName,physicalDeliveryOfficeName,msExchHomeServerName,streetAddress,telephoneNumber,accountExpires
}
$Target = $user |
Select-Object cn, `
@{name='pwdLastSetDateTime'; `
expression={[datetime]::fromFileTime($_.pwdlastset)}}, `
@{name='badPasswordTimeDateTime'; `
expression={[datetime]::fromFileTime($_.badPasswordTime)}}, `
@{name='lastLogonDateTime'; `
expression={[datetime]::fromFileTime($_.lastLogon)}}, `
@{name='AccountExpiresTime'; `
expression={[datetime]::fromFileTime($_.accountExpires)}}, `
@{name='pwdNextExpireDateTime'; `
expression={Get-Date([datetime]::fromFileTime($_.pwdlastset)).AddDays(90)} },whenCreated,whenChanged,PasswordNeverExpires,lockedout,badpwdcount,mail,c,city,country,department,Description,manager,memberof,`
DistinguishedName,employeeID,givenname,targetAddress,title,sn,msRTCSIP-PrimaryUserAddress,sAMAccountName,`
displayName,userPrincipalName,physicalDeliveryOfficeName,msExchHomeServerName,streetAddress,telephoneNumber
$pwdLastSetDateTime = $Target.pwdLastSetDateTime |Out-String
$badPasswordTimeDateTime = $Target.badPasswordTimeDateTime |Out-String
$lastLogonDateTime = $Target.lastLogonDateTime |Out-String
$pwdNextExpireDateTime = $Target.pwdNextExpireDateTime |Out-String
#$lastLogonDateTime = $Target.lastLogonDateTime |Out-String
$whenCreated = $Target.whenCreated |Out-String
$whenChanged = $Target.whenChanged |Out-String
$AccountExpiresTime = $Target.AccountExpiresTime |Out-String
$PasswordNeverExpires = $Target.PasswordNeverExpires |Out-String
$lockedout = $Target.lockedout |Out-String
$badpwdcount = $Target.badpwdcount |Out-String
$mail = $Target.mail |Out-String
$c = $Target.c |Out-String
$city = $Target.city |Out-String
$country = $Target.country |Out-String
$department = $Target.department |Out-String
$Description = $Target.Description |Out-String
$manager = $Target.manager |Out-String
$memberof = $Target.memberof |Out-String
$DistinguishedName = $Target.DistinguishedName |Out-String
$userPrincipalName = $Target.userPrincipalName |Out-String
$employeeID = $Target.employeeID |Out-String
$givenname = $Target.givenname |Out-String
$targetAddress = $Target.targetAddress |Out-String
$title = $Target.title |Out-String
$sn = $Target.sn |Out-String
$LyncSIP = $Target.'msRTCSIP-PrimaryUserAddress' |Out-String
$sAMAccountName = $Target.sAMAccountName |Out-String
$displayName = $Target.displayName |Out-String
$physicalDeliveryOfficeName = $Target.physicalDeliveryOfficeName |Out-String
$msExchHomeServerName = $Target.msExchHomeServerName |Out-String
$streetAddress = $Target.streetAddress |Out-String
$telephoneNumber = $Target.telephoneNumber |Out-String
#########################################################
$TxtDisplayname.Text = $displayName
$TxtUPN.Text = $userPrincipalName
$TxtLastName.Text = $sn
$TxtFirstName.Text = $givenname
$TxtDepartment.Text = $department
$TxtCity.Text = $city
$TxtLANID.Text = $sAMAccountName
$TxtTitle.Text = $title
$TxtO365.Text = $targetAddress
$TxtOfficeCode.Text = $physicalDeliveryOfficeName
$TxtStreetAddress.Text = $streetAddress
$TxtInteralExchange.Text = $msExchHomeServerName
$TxtEmployeeID.Text = $employeeID
$TxtEmaiAddress.Text = $mail
$TxtLyncSIP.Text = $LyncSIP
$TxtTelephoneNumber.Text = $telephoneNumber
$TxtCountry.Text = $country
$TxtDescription.Text = $Description
$TxtManager.Text = $manager
$TxtpwdLastSetDateTime.Text = $pwdLastSetDateTime
$TxtBadPasswordTime.Text = $badPasswordTimeDateTime
$TxtLastLogonTime.Text = $lastLogonDateTime
$TxtPasswordExpiresime.Text = $pwdNextExpireDateTime
$TxtAccountCreatedAt.Text = $DistinguishedName
$TxtwhenCreated.Text = $whenCreated
$TxtwhenChanged.Text = $whenChanged
$TxtPasswordNeverExpires.Text = $PasswordNeverExpires
$TxtLockedout.Text = $lockedout
$Txtbadpwdcount.Text = $badpwdcount
$Txtmemberof.Text = $memberof
$TxtaccountExpires.Text = $AccountExpiresTime
if($TxtaccountExpires.Text -like '*1601*')
{$TxtaccountExpires.Text = 'NEVER'}
else
{$TxtaccountExpires.Text = $AccountExpiresTime}
#########################################################
})
$MainForm.Controls.Add($OKButton)
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Size(900,750)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = "Cancel"
$CancelButton.Add_Click({$MainForm.Close()})
$MainForm.Controls.Add($CancelButton)
$MainForm.Topmost = $False
$MainForm.Add_Shown({
$MainForm.Activate()
})
[void] $MainForm.ShowDialog()
本文链接: https://www.pstips.net/gui-tool-to-get-ad-user.html
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!
