Skip to content

Instantly share code, notes, and snippets.

Created November 12, 2019 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shoebsd31/752981f292bd191f73a48b18ddea84b7 to your computer and use it in GitHub Desktop.
Save shoebsd31/752981f292bd191f73a48b18ddea84b7 to your computer and use it in GitHub Desktop.
basic powershell to get read user data
This is a script to gather information for Help Desk support calls
This is a basic script designed to gather user and computer information for helpdeks support calls.
Information gathered includes:
DNS Name & IP Address
DNS Server
Name of Operating System
Amount of Memory in target computer
Amount of free space on disk
Last Reboot of System
Last User Logon Date
Group Membership of User
Printers on System
PS C:\scripts\M5> .\get-helpdesksupportdata.ps1
cmdlet get-helpdesksupportdata.ps1 at command pipeline position 1
Supply values for the following parameters:
ComputerName: client02
Username: mbender
In this example, the script is simply run and the parameters are input as they are mandatory.
Get-SupportInfo.ps1 -ComputerName Client1 -Username usrmvb
This example has mandatory parameters input when calling script.
Get-SupportInfo.ps1 -ComputerName Client1 -Username usrmvb | out-file c:\UserInfo.txt
This example sends the output of the script to a text file.
#Michael Bender
#July 31, 2015
#August 14, 2015
##Paramaters for Computername & UserName
Param (
#IP Address
$DNSFQDN = Resolve-DnsName -Name $ComputerName | select Name,IPaddress
#DNS Server
$DNSServer= (Get-DNSClientServerAddress `
-cimsession (New-CimSession -computername $ComputerName) `
-InterfaceAlias "ethernet0" -AddressFamily IPv4).ServerAddresses
#OS Description -
$OS= (Get-CimInstance Win32_OperatingSystem -ComputerName $ComputerName).caption
$memory = ((((Get-CimInstance Win32_PhysicalMemory -ComputerName $Computername).Capacity|measure -Sum).Sum)/1gb)
#Last Reboot
$Reboot = (Get-CIMInstance -Class Win32_OperatingSystem –ComputerName $ComputerName).LastBootUpTime
$drive =Invoke-Command -ComputerName client02 {get-psdrive| where Name -EQ "C"}
$Freespace =[Math]::Round(($,2)
$LastLogonUser = (Get-ADUser -Identity $Username -Property *).LastLogonDate
If ($LastLogonUser -eq $null) {
$LastLogonUser = "User has not logged onto network since account creation"
#Retrieve Group Membership of AD User Account
$ADGroupMembership = (get-aduser -Identity $Username -property *).memberof
$Printers = Get-Printer -ComputerName $Computername | Select -Property Name,DriverName,Type | ft -AutoSize
#Write Output to Screen & Make available for pipeline commands
Write-Output "Username: $username" ; ""
Write-Output $UserAccounts;""
Write-Output "DNS Name & IP Address of Target:"
Write-Output $DNSFQDN;""
Write-Output "DNS Server of Target: $DNSServer";""
Write-Output "Last User Logon Attempt: $LastLogonUser";""
Write-output "Computername: $Computername";""
Write-Output "Total System RAM: $memory GB";""
Write-Output "Freespace on C: $Freespace GB"
Write-Output "Printers Installed: "
Write-Output $Printers
Write-Output "Group Membership ( Displayed as Distinguished Name )"
Write-Output $ADGroupMembership
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment