-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathPostConfig.ps1
77 lines (70 loc) · 3.11 KB
/
PostConfig.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
[Cmdletbinding()]
Param(
[parameter(Mandatory)]
[string]
$WindowsUpdate,
[parameter(Mandatory)]
[string]
$Restart,
[parameter(Mandatory)]
[string]
$VDOT
)
##############################################################
# FUNCTIONS
##############################################################
function Write-Log
{
param(
[parameter(Mandatory)]
[string]$Message,
[parameter(Mandatory)]
[string]$Type
)
$Path = 'C:\cse.txt'
if(!(Test-Path -Path $Path))
{
New-Item -Path 'C:\' -Name 'cse.txt' | Out-Null
}
$Timestamp = Get-Date -Format 'MM/dd/yyyy HH:mm:ss.ff'
$Entry = '[' + $Timestamp + '] [' + $Type + '] ' + $Message
$Entry | Out-File -FilePath $Path -Append
}
########################################################################################
# WINDOWS AND APP UPDATES - issues with winget store app not being updated and unable to update during post config
########################################################################################
<#
if($AllAppsUpdate.ToUpper() -eq 'TRUE'){
Invoke-WebRequest -Uri https://github.com/microsoft/winget-cli/releases/download/v1.4.10173/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle -OutFile C:\Windows\Temp\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
Invoke-WebRequest -Uri https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile C:\Windows\Temp\Microsoft.VCLibs.x64.14.00.Desktop.appx
Add-AppxProvisionedPackage -Online -PackagePath C:\Windows\Temp\Microsoft.VCLibs.x64.14.00.Desktop.appx -SkipLicense
Add-AppxProvisionedPackage -Online -PackagePath C:\Windows\Temp\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle -SkipLicense
# Winget to update all Apps
& 'C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.19.10173.0_x64__8wekyb3d8bbwe\winget.exe' upgrade -h --all --accept-source-agreements --disable-interactivity
}
#>
if($WindowsUpdate.ToUpper() -eq 'TRUE'){
# Windows Update Exectution
Install-PackageProvider -Name Nuget -Force
Install-Module -Name PSWindowsUpdate -Force -AllowClobber
Get-WindowsUpdate -AcceptAll -IgnoreReboot
Install-WindowsUpdate -AcceptAll -ForceDownload -ForceInstall -IgnoreReboot
}
##############################################################
# Run VDOT
##############################################################
If($VDOT.ToUpper() -eq 'TRUE'){
# Download VDOT
Invoke-WebRequest -Uri https://github.com/The-Virtual-Desktop-Team/Virtual-Desktop-Optimization-Tool/archive/refs/heads/main.zip -OutFile C:\VDOT\VDOT.zip
# Extract Zip
Expand-Archive -Path C:\VDOT\VDOT.zip -DestinationPath C:\VDOT -Force
# Execute without Restart
C:\VDOT\Windows_VDOT.ps1 -Optimizations AppxPackages -AcceptEula -Verbose
}
########################################################################################
# REBOOT VM
########################################################################################
if($Restart.ToUpper() -eq 'TRUE'){
# Reboot VM - Typically the last function
Restart-Computer -Force
}