-
Notifications
You must be signed in to change notification settings - Fork 0
/
CheckSRVSYSversionManu.ps1
128 lines (128 loc) · 2.67 KB
/
CheckSRVSYSversionManu.ps1
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
124
125
126
127
128
$os = Get-WmiObject -class Win32_OperatingSystem
$osName = $os.Caption
$s = "%systemroot%\system32\drivers\srv.sys"
$v = [System.Environment]::ExpandEnvironmentVariables($s)
$version = (Get-Item $v).VersionInfo.FileVersionRaw.ToString().Split('.')
if ($version.Length -ne 4)
{
"Version number not recognised."
return
}
if ($osName.Contains("Vista") -or ($osName.Contains("2008") -and -not $osName.Contains("R2")))
{
if (([string]($version[3]))[0] -eq "1")
{
"OS is " + $osName + " GDR"
"Patch version is 6.0.6002.19743"
$patchVer = 6,0,6002,19743
}
elseif (([string]($version[3]))[0] -eq "2")
{
"OS is " + $osName + " LDR"
"Patch version is 6.0.6002.24067"
$patchVer = 6,0,6002,24067
}
else
{
"OS is " + $osName
"Patch version is UNKNOWN"
$patchVer = 99999,99999,99999,99999
}
}
elseif ($osName.Contains("Windows 7") -or ($osName.Contains("2008 R2")))
{
"OS is " + $osName + " LDR"
"Patch version is 6.1.7601.23689"
$patchVer = 6,1,7601,23689
}
elseif ($osName.Contains("Windows 8.1") -or $osName.Contains("2012 R2"))
{
"OS is " + $osName + " LDR"
"Patch version is 6.3.9600.18604"
$patchVer = 6,3,9600,18604
}
elseif ($osName.Contains("Windows 8") -or $osName.Contains("2012"))
{
"OS is " + $osName + " LDR"
"Patch version is 6.2.9200.22099"
$patchVer = 6,2,9200,22099
}
elseif ($osName.Contains("Windows 10"))
{
if ($os.BuildNumber -eq "10240")
{
"OS is " + $osName + " TH1"
"Patch version is 10.0.10240.17319"
$patchVer = 10,0,10240,17319
}
elseif ($os.BuildNumber -eq "10586")
{
"OS is " + $osName + " TH2"
"Patch version is 10.0.10586.839"
$patchVer = 10,0,10586,839
}
elseif ($os.BuildNumber -eq "14393")
{
"OS is " + $osName + " RS1"
"Patch version is 10.0.14393.953"
$patchVer = 10,0,14393,953
}
elseif ($os.BuildNumber -eq "15063")
{
"OS is " + $osName + " RS2"
"No need to Patch. RS2 is released as patched. "
return
}
}
elseif ($osName.Contains("2016"))
{
"OS is " + $osName
"Patch version is 10.0.14393.953"
$patchVer = 10,0,14393,953
}
else
{
"OS is " + $osName
"Patch version is UNKNOWN"
$patchVer = 99999,99999,99999,99999
}
if ($version[0] -gt $patchVer[0])
{
"Patch already applied"
return
}
if ($version[0] -lt $patchVer[0])
{
"Patch NOT applied yet"
return
}
if ($version[1] -gt $patchVer[1])
{
"Patch already applied"
return
}
if ($version[1] -lt $patchVer[1])
{
"Patch NOT applied yet"
return
}
if ($version[2] -gt $patchVer[2])
{
"Patch already applied"
return
}
if ($version[2] -lt $patchVer[2])
{
"Patch NOT applied yet"
return
}
if ($version[3] -ge $patchVer[3])
{
"Patch already applied"
return
}
if ($version[3] -lt $patchVer[3])
{
"Patch NOT applied yet"
return
}