-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathGet-PCInfo Function.ps1
More file actions
123 lines (92 loc) · 4.18 KB
/
Get-PCInfo Function.ps1
File metadata and controls
123 lines (92 loc) · 4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
Function Get-PCInfo {
<#
.Synopsis
By Taylor Lee
Modified 05212018
.Description
This scripts function returns useful informaion on any machine.
.Inputs
Param (
$Computer
)
#Variables
$SystemEnclosure = get-ciminstance win32_systemenclosure -computername $computer
$OS = Get-CimInstance Win32_OperatingSystem -Computername $Computer
#Creating Hash table from variables
$PCInfo = @{
Manufacturer=$SystemEnclosure.Manufacturer
PCName=$OS.CSName
OS=$OS.Caption
Architecture=$OS.OSArchitecture
AssetTag=$systemenclosure.serialnumber;
OSVersion=$OS.Version
InstallDate=$OS.InstallDate
LastBootUpTime=$OS.LastBootUpTime
}
#Writing to Host
Write-host " "
Write-host "If not run on a Dell machine AssetTag is the Serial Number" -Foregroundcolor Yellow
Write-host "Computer Info" -Foregroundcolor Cyan
#Display Hash Table
$PCInfo.getenumerator() | sort-object -property name | ft -autosize
#Writing to Host
Write-host "Computer Disk Info" -Foregroundcolor Cyan
#Display Drives
Get-CimInstance win32_logicaldisk -filter "drivetype=3" -computer $computer |
Format-Table -Property DeviceID,Volumename, `
@{Name="SizeGB";Expression={[math]::Round($_.Size/1GB)}}, `
@{Name="FreeGB";Expression={[math]::Round($_.Freespace/1GB,2)}}, `
@{Name="PercentFree";Expression={[math]::Round(($_.Freespace/$_.size)*100,2)}}
#Writing to Host
Write-host "Network Information" -Foregroundcolor Cyan
Get-CimInstance win32_networkadapterconfiguration | where {$_.IPAddress -ne $null} |
select IPAddress,DefaultIPGateway,DNSServerSearchOrder,IPSubnet,MACAddress,Caption,DHCPEnabled,DHCPServer,DNSDomainSuffixSearchOrder |
fl
.NOTES
Requires latest powershell version
.EXAMPLE
Returns PCinfo for the local computer
Get-PCinfo
.EXAMPLE
Returns PCinfo for a remote computer
Get-PCinfo -computer PCName
#>
[CmdletBinding()]
#Prompts for Computer Name
Param (
$Computer
)
#Variables
$SystemEnclosure = get-ciminstance win32_systemenclosure -computername $computer
$OS = Get-CimInstance Win32_OperatingSystem -Computername $Computer
#Creating Hash table from variables
$PCInfo = @{
Manufacturer=$SystemEnclosure.Manufacturer
PCName=$OS.CSName
OS=$OS.Caption
Architecture=$OS.OSArchitecture
AssetTag=$systemenclosure.serialnumber;
OSVersion=$OS.Version
InstallDate=$OS.InstallDate
LastBootUpTime=$OS.LastBootUpTime
}
#Writing to Host
Write-host " "
Write-host "If not run on a Dell machine AssetTag is the Serial Number" -Foregroundcolor Yellow
Write-host "Computer Info" -Foregroundcolor Cyan
#Display Hash Table
$PCInfo.getenumerator() | Sort-Object -property name | Format-Table -autosize
#Writing to Host
Write-host "Computer Disk Info" -Foregroundcolor Cyan
#Display Drives
Get-CimInstance win32_logicaldisk -filter "drivetype=3" -computer $computer |
Format-Table -Property DeviceID,Volumename, `
@{Name="SizeGB";Expression={[math]::Round($_.Size/1GB)}}, `
@{Name="FreeGB";Expression={[math]::Round($_.Freespace/1GB,2)}}, `
@{Name="PercentFree";Expression={[math]::Round(($_.Freespace/$_.size)*100,2)}}
#Writing to Host
Write-host "Network Information" -Foregroundcolor Cyan
Get-CimInstance win32_networkadapterconfiguration -computer $computer | Where-Object {$_.IPAddress -ne $null} |
Select-Object IPAddress,DefaultIPGateway,DNSServerSearchOrder,IPSubnet,MACAddress,Caption,DHCPEnabled,DHCPServer,DNSDomainSuffixSearchOrder |
Format-List
}