forked from jajp777/powershell-scripts-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Invoke-NgenUpdate.ps1
61 lines (44 loc) · 1.82 KB
/
Invoke-NgenUpdate.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
function Invoke-NgenUpdate {
[CmdletBinding()]
param(
[string]
$NgenPath32v4 = 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\ngen.exe',
[string]
$NgenPath64v4 = 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe',
[string]
$NgenPath32v2 = 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\ngen.exe',
[string]
$NgenPath64v2 = 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\ngen.exe',
[string]
$NgenArgs = 'update /force',
[string]
$TempFile = (Join-Path -Path $env:TEMP -ChildPath $(([System.Guid]::NewGuid().Guid) + '.txt'))
) #param
process {
$SplatArgs = @{ FilePath = $NgenPath32v4
ArgumentList = $NgenArgs
NoNewWindow = $true
Wait = $true
RedirectStandardOutput = $TempFile }
Start-Process @SplatArgs
$SplatArgs = @{ FilePath = $NgenPath64v4
ArgumentList = $NgenArgs
NoNewWindow = $true
Wait = $true
RedirectStandardOutput = $TempFile }
Start-Process @SplatArgs
$SplatArgs = @{ FilePath = $NgenPath32v2
ArgumentList = $NgenArgs
NoNewWindow = $true
Wait = $true
RedirectStandardOutput = $TempFile }
Start-Process @SplatArgs
$SplatArgs = @{ FilePath = $NgenPath64v2
ArgumentList = $NgenArgs
NoNewWindow = $true
Wait = $true
RedirectStandardOutput = $TempFile }
Start-Process @SplatArgs
Remove-Item -Path $TempFile | Out-Null
} #process
} #function Invoke-NgenUpdate