Skip to content

Commit

Permalink
Update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronparker committed Dec 4, 2023
1 parent 42f9f4e commit dd09320
Show file tree
Hide file tree
Showing 13 changed files with 187 additions and 29 deletions.
File renamed without changes.
39 changes: 39 additions & 0 deletions scripts/image/215_MicrosoftPowerShell.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#description: Installs the latest Microsoft PowerShell
#execution mode: Combined
#tags: Evergreen, Microsoft, PowerShell
#Requires -Modules Evergreen
[System.String] $Path = "$Env:SystemDrive\Apps\Microsoft\PowerShell"

#region Script logic
New-Item -Path $Path -ItemType "Directory" -Force -ErrorAction "SilentlyContinue" | Out-Null
New-Item -Path "$Env:ProgramData\Nerdio\Logs" -ItemType "Directory" -Force -ErrorAction "SilentlyContinue" | Out-Null

try {
Import-Module -Name "Evergreen" -Force
$App = Get-EvergreenApp -Name "MicrosoftPowerShell" | `
Where-Object { $_.Architecture -eq "x64" -and $_.Release -eq "Stable" } | `
Select-Object -First 1
$OutFile = Save-EvergreenApp -InputObject $App -CustomPath $Path -WarningAction "SilentlyContinue"
}
catch {
throw $_
}

try {
Write-Information -MessageData ":: Install Microsoft PowerShell" -InformationAction "Continue"
$LogFile = "$Env:ProgramData\Nerdio\Logs\MicrosoftPowerShell$($App.Version).log" -replace " ", ""
$params = @{
FilePath = "$Env:SystemRoot\System32\msiexec.exe"
ArgumentList = "/package `"$($OutFile.FullName)`" /quiet /norestart ALLUSERS=1 /log $LogFile"
NoNewWindow = $true
Wait = $true
PassThru = $true
ErrorAction = "Continue"
}
$result = Start-Process @params
Write-Information -MessageData ":: Install exit code: $($result.ExitCode)" -InformationAction "Continue"
}
catch {
throw $_
}
#endregion
33 changes: 33 additions & 0 deletions scripts/image/421_1PasswordCli.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#description: Installs the latest 1Password CLI
#execution mode: Combined
#tags: Evergreen, 1Password

#Requires -Modules Evergreen
[System.String] $Path = "$Env:ProgramFiles\1Password CLI"

#region Script logic
New-Item -Path $Path -ItemType "Directory" -Force -ErrorAction "SilentlyContinue" | Out-Null
New-Item -Path "$Env:ProgramData\Nerdio\Logs" -ItemType "Directory" -Force -ErrorAction "SilentlyContinue" | Out-Null

try {
# Download - update when Evergreen supports 1Password CLI
$App = [PSCustomObject]@{
Version = "2.23.0"
URI = "https://cache.agilebits.com/dist/1P/op2/pkg/v2.23.0/op_windows_amd64_v2.23.0.zip"
}
$OutFile = Save-EvergreenApp -InputObject $App -CustomPath $Path -WarningAction "SilentlyContinue"
Expand-Archive -Path $OutFile.FullName -DestinationPath $Path -Force
Remove-Item -Path $OutFile.FullName -Force -ErrorAction "SilentlyContinue"

# Add $Path to the system Path environment variable if it doesn't already exist
if ([System.Environment]::GetEnvironmentVariable($Env:Path) -match "1Password") {}
else {
[System.Environment]::SetEnvironmentVariable("Path",
[System.Environment]::GetEnvironmentVariable("Path",
[System.EnvironmentVariableTarget]::Machine) + ";$Path",
[System.EnvironmentVariableTarget]::Machine)
}
}
catch {
throw $_
}
8 changes: 4 additions & 4 deletions scripts/image/999_CleanupImage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ if (Test-Path -Path "$Env:SystemDrive\Apps") { Remove-Item -Path "$Env:SystemDri
if (Test-Path -Path "$Env:SystemDrive\DeployAgent") { Remove-Item -Path "$Env:SystemDrive\DeployAgent" -Recurse -Force -ErrorAction "SilentlyContinue" }

# Remove items from the Temp directory (note that scripts run as SYSTEM)
Get-ChildItem -Path "$Env:Temp" -Include "*.*" -Recurse -ErrorAction "SilentlyContinue" | `
Remove-Item -Force -ErrorAction "SilentlyContinue"
Remove-Item -Path $Env:Temp -Recurse -Force -Confirm:$false -ErrorAction "SilentlyContinue"
New-Item -Path $Env:Temp -ItemType "Directory" -ErrorAction "SilentlyContinue" | Out-Null

# Remove logs older than 30 days
Get-ChildItem -Path "$Env:ProgramData\Nerdio\Logs" -Include "*.*" -Recurse | `
Get-ChildItem -Path "$Env:ProgramData\Nerdio\Logs" -Include "*.*" -Recurse -ErrorAction "SilentlyContinue" | `
Where-Object { ($_.LastWriteTime -lt (Get-Date).AddDays(-30)) -and ($_.psIsContainer -eq $false) } | `
Remove-Item -Force -ErrorAction "SilentlyContinue"
ForEach-Object { Remove-Item -Path $_.FullName -Force -Confirm:$false -ErrorAction "SilentlyContinue" }

# Disable Windows Update
# reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v "NoAutoUpdate" /t REG_DWORD /d 1 /f
File renamed without changes.
15 changes: 15 additions & 0 deletions tests/image/Apps.json
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,21 @@
"C:\\Program Files\\RemoteDisplayAnalyzer\\RemoteDisplayAnalyzer.exe"
]
},
{
"Name": "CitrixWorkspaceApp",
"Filter": "Get-EvergreenApp -Name \"CitrixWorkspaceApp\" | Where-Object { $_.Stream -eq \"Current\" } | Select-Object -First 1",
"Installed": "Citrix Workspace*",
"FilesExist": [
"C:\\Program Files (x86)\\Citrix\\ICA Client\\SelfServicePlugin\\SelfService.exe",
"C:\\Program Files (x86)\\Citrix\\ICA Client\\SelfServicePlugin\\SelfServicePlugin.exe",
"C:\\Program Files (x86)\\Citrix\\ICA Client\\wfica32.exe",
"C:\\Program Files (x86)\\Citrix\\ICA Client\\wfcrun32.exe"
],
"ShortcutsNotExist": [],
"ServicesDisabled": [
"CWAUpdaterService"
]
},
{
"Name": "ConnectionExperienceIndicator",
"Filter": "Get-EvergreenApp -Name ConnectionExperienceIndicator",
Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/3_RunImageScripts.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ BeforeDiscovery {
$SupportScripts = Get-ChildItem -Path $Path -Include "0*.ps1" -Recurse -Exclude "012_WindowsUpdate.ps1"
$DependencyScripts = Get-ChildItem -Path $Path -Include "1*.ps1" -Recurse -Exclude "101_Avd-Agents.ps1"
$MicrosoftAppsScripts = Get-ChildItem -Path $Path -Include "2*.ps1" -Recurse
$3rdPartyScripts = Get-ChildItem -Path $Path -Include "4*.ps1" -Recurse -Exclude "499_CrowdStrikeWindowsSensor.ps1", "418_Synapse.ps1"
$3rdPartyScripts = Get-ChildItem -Path $Path -Include "4*.ps1" -Recurse
$CleanupScripts = Get-ChildItem -Path $Path -Include "9*.ps1" -Recurse

$2ndRunScripts = Get-ChildItem -Path $Path -Include "201_MicrosoftTeams.ps1" -Recurse
Expand Down
23 changes: 16 additions & 7 deletions tests/scripts/4_ValidateApps.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Describe "Validate <App.Name>" -ForEach $Applications {
New-PSDrive @params | Out-Null
}
catch {
throw $_
throw $_.Exception.Message
}

$UninstallKeys = @(
Expand All @@ -72,14 +72,14 @@ Describe "Validate <App.Name>" -ForEach $Applications {
Sort-Object -Property "DisplayName", "Publisher"
}
catch {
throw $_
throw $_.Exception.Message
}
}

return $Apps
}
catch {
throw $_
throw $_.Exception.Message
}
finally {
Remove-PSDrive "HKU" -ErrorAction "SilentlyContinue" | Out-Null
Expand All @@ -92,7 +92,16 @@ Describe "Validate <App.Name>" -ForEach $Applications {

# Get details for the current application
$App = $_
$Latest = Invoke-Expression -Command $App.Filter

if ([SYstem.String]::IsNullOrEmpty($App.Filter)) {
$Latest = [PSCustomObject]@{
Version = "1.1.0"
}
}
else {
$Latest = Invoke-Expression -Command $App.Filter
}

$Installed = $InstalledSoftware | `
Where-Object { $_.Name -match $App.Installed } | `
Sort-Object -Property @{ Expression = { [System.Version]$_.Version }; Descending = $true } | `
Expand Down Expand Up @@ -142,7 +151,7 @@ AfterAll {
New-PSDrive @params | Out-Null
}
catch {
throw $_
throw $_.Exception.Message
}

$UninstallKeys = @(
Expand All @@ -164,14 +173,14 @@ AfterAll {
Sort-Object -Property "DisplayName", "Publisher"
}
catch {
throw $_
throw $_.Exception.Message
}
}

return $Apps
}
catch {
throw $_
throw $_.Exception.Message
}
finally {
Remove-PSDrive "HKU" -ErrorAction "SilentlyContinue" | Out-Null
Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/5_ValidateConfigs.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ BeforeDiscovery {
Describe "Microsoft Edge configuration" {
Context "Application preferences" {
It "Should have written the correct content to master_preferences" {
(Get-Content -Path "${Env:ProgramFiles(x86)}\Microsoft\Edge\Application\master_preferences" | ConvertFrom-Json).homepage | Should -BeExactly "https://www.office.com"
(Get-Content -Path "${Env:ProgramFiles(x86)}\Microsoft\Edge\Application\master_preferences" | ConvertFrom-Json).homepage | Should -BeExactly "https://www.microsoft365.com"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/6_RunTweaksScripts.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ BeforeDiscovery {
}

# Get the scripts to test
$Scripts = Get-ChildItem -Path $Path -Include "*.ps1" -Recurse -Exclude "Enable-SysprepCryptoSysPrep_Specialize.ps1", "Install-FSLogixAppMaskingRuleset.ps1"
$Scripts = Get-ChildItem -Path $Path -Include "*.ps1" -Recurse -Exclude "Enable-SysprepCryptoSysPrep_Specialize.ps1", "Install-FSLogixAppMaskingRuleset.ps1", "Set-FSLogixStorageAccount.ps1"
}

Describe "Run tweaks scripts" {
Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/7_RunOptimiseScripts.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ BeforeDiscovery {
}

# Get the scripts to test
$Scripts = Get-ChildItem -Path $Path -Include "*.ps1" -Recurse -Exclude "Install-MicrosoftVdot.ps1"
$Scripts = Get-ChildItem -Path $Path -Include "*.ps1" -Recurse -Exclude "Install-MicrosoftVdot.ps1", "Install-CitrixOptimizer.ps1"
}

Describe "Run optimise scripts" {
Expand Down
90 changes: 76 additions & 14 deletions tests/scripts/Apps.json
Original file line number Diff line number Diff line change
Expand Up @@ -306,29 +306,91 @@
"ServicesDisabled": []
},
{
"Name": "CitrixWorkspaceApp",
"Filter": "Get-EvergreenApp -Name \"CitrixWorkspaceApp\" | Where-Object { $_.Stream -eq \"Current\" } | Select-Object -First 1",
"Installed": "Citrix Workspace*",
"Name": "MicrosoftSsms",
"Filter": "Get-EvergreenApp -Name \"MicrosoftSsms\" | Where-Object { $_.Language -eq \"English\" } | Select-Object -First 1",
"Installed": "Microsoft SQL Server Management Studio*",
"FilesExist": [
"C:\\Program Files (x86)\\Citrix\\ICA Client\\SelfServicePlugin\\SelfService.exe",
"C:\\Program Files (x86)\\Citrix\\ICA Client\\SelfServicePlugin\\SelfServicePlugin.exe",
"C:\\Program Files (x86)\\Citrix\\ICA Client\\wfica32.exe",
"C:\\Program Files (x86)\\Citrix\\ICA Client\\wfcrun32.exe"
"C:\\Program Files (x86)\\Microsoft SQL Server Management Studio 19\\Common7\\IDE\\Ssms.exe"
],
"ShortcutsNotExist": [],
"ServicesDisabled": [
"CWAUpdaterService"
]
},
{
"Name": "MicrosoftSsms",
"Filter": "Get-EvergreenApp -Name \"MicrosoftSsms\" | Where-Object { $_.Language -eq \"English\" } | Select-Object -First 1",
"Installed": "Microsoft SQL Server Management Studio*",
"Name": "1Password",
"Filter": "Get-EvergreenApp -Name \"1Password\" | Select-Object -First 1",
"Installed": "1Password*",
"FilesExist": [
"C:\\Program Files (x86)\\Microsoft SQL Server Management Studio 19\\Common7\\IDE\\Ssms.exe"
"C:\\Program Files\\1Password\\app\\8\\1Password.exe"
],
"ShortcutsNotExist": [],
"ServicesDisabled": [
]
"ServicesDisabled": []
},
{
"Name": "Microsoft Azure CLI",
"Filter": "Get-EvergreenApp -Name \"MicrosoftAzureCLI\" | Where-Object { $_.Type -eq \"msi\" } | Select-Object -First 1",
"Installed": "Microsoft Azure CLI*",
"FilesExist": [
"C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI2\\python.exe",
"C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI2\\pythonw.exe",
"C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI2\\wbin\\az.cmd",
"C:\\Program Files (x86)\\Microsoft SDKs\\Azure\\CLI2\\wbin\\azps.ps1"
],
"ShortcutsNotExist": [],
"ServicesDisabled": []
},
{
"Name": "Microsoft Visual Studio Code",
"Filter": "Get-EvergreenApp -Name \"MicrosoftVisualStudioCode\" | Where-Object { $_.Architecture -eq \"x64\" -and $_.Platform -eq \"win32-x64\" -and $_.Channel -eq \"Stable\" } | Select-Object -First 1",
"Installed": "Microsoft Visual Studio Code*",
"FilesExist": [
"C:\\Program Files\\Microsoft VS Code\\Code.exe"
],
"ShortcutsNotExist": [],
"ServicesDisabled": []
},
{
"Name": "Microsoft PowerToys",
"Filter": "Get-EvergreenApp -Name \"MicrosoftPowerToys\" | Where-Object { $_.Architecture -eq \"x64\" -and $_.InstallerType -eq \"Default\" }",
"Installed": "PowerToys*",
"FilesExist": [
"C:\\Program Files\\PowerToys\\PowerToys.exe",
"C:\\Program Files\\PowerToys\\PowerToys.FancyZones.exe",
"C:\\Program Files\\PowerToys\\PowerToys.FancyZonesEditor.exe"
],
"ShortcutsNotExist": [],
"ServicesDisabled": []
},
{
"Name": "Zoom Client for VDI",
"Filter": "",
"Installed": "Zoom Client for VDI*",
"FilesExist": [
"C:\\Program Files\\ZoomVDI\\bin\\Zoom.exe",
"C:\\Program Files\\ZoomVDI\\bin\\ZoomVDITool.exe"
],
"ShortcutsNotExist": [],
"ServicesDisabled": []
},
{
"Name": "Microsoft PowerShell",
"Filter": "Get-EvergreenApp -Name \"MicrosoftPowerShell\" | Where-Object { $_.Architecture -eq \"x64\" -and $_.Release -eq \"Stable\" } | Select-Object -First 1",
"Installed": "PowerShell*",
"FilesExist": [
"C:\\Program Files\\PowerShell\\7\\pwsh.exe"
],
"ShortcutsNotExist": [],
"ServicesDisabled": []
},
{
"Name": "1Password CLI",
"Filter": "",
"Installed": "1Password*",
"FilesExist": [
"C:\\Program Files\\1Password CLI\\op.exe",
"C:\\Program Files\\1Password CLI\\op.exe.sig"
],
"ShortcutsNotExist": [],
"ServicesDisabled": []
}
]

0 comments on commit dd09320

Please sign in to comment.