2020-07-20 07:48:50 +00:00
|
|
|
Describe "WindowsFeatures" {
|
2021-08-03 20:17:31 +03:00
|
|
|
$windowsFeatures = (Get-ToolsetContent).windowsFeatures
|
|
|
|
|
$testCases = $windowsFeatures | ForEach-Object { @{ Name = $_.name; OptionalFeature = $_.optionalFeature } }
|
|
|
|
|
|
|
|
|
|
It "Windows Feature <Name> is installed" -TestCases $testCases {
|
|
|
|
|
if ($OptionalFeature) {
|
|
|
|
|
(Get-WindowsOptionalFeature -Online -FeatureName $Name).State | Should -Be "Enabled"
|
|
|
|
|
} else {
|
|
|
|
|
(Get-WindowsFeature -Name $Name).InstallState | Should -Be "Installed"
|
2020-07-20 07:48:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-26 15:53:15 +02:00
|
|
|
it "Check WSL is on path" {
|
2021-08-03 20:17:31 +03:00
|
|
|
(Get-Command -Name 'wsl') | Should -BeTrue
|
2020-07-20 07:48:50 +00:00
|
|
|
}
|
2024-02-22 16:12:24 +01:00
|
|
|
|
|
|
|
|
it "Check WLAN service is stopped" {
|
|
|
|
|
(Get-Service -Name wlansvc).Status | Should -Be "Stopped"
|
|
|
|
|
}
|
2020-07-20 07:48:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Describe "DiskSpace" {
|
2025-10-03 11:25:31 +02:00
|
|
|
It "The image has enough disk space" {
|
|
|
|
|
$diskInfo = Get-PSDrive -Name C
|
|
|
|
|
$totalSpaceGB = [math]::Floor(($diskInfo.Used + $diskInfo.Free) / 1GB)
|
|
|
|
|
$freeSpaceGB = [math]::Floor($diskInfo.Free / 1GB)
|
|
|
|
|
Write-Host " [i] Disk size: ${totalSpaceGB} GB; Free space: ${freeSpaceGB} GB"
|
|
|
|
|
$freeSpaceGB | Should -BeGreaterOrEqual 18
|
2020-07-20 07:48:50 +00:00
|
|
|
}
|
2020-08-24 09:44:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Describe "DynamicPorts" {
|
|
|
|
|
It "Test TCP dynamicport start=49152 num=16384" {
|
2023-12-11 22:23:36 +01:00
|
|
|
$tcpPorts = Get-NetTCPSetting | Where-Object { $_.SettingName -ne "Automatic" } | Where-Object {
|
2020-08-24 09:44:21 +03:00
|
|
|
$_.DynamicPortRangeStartPort -ne 49152 -or $_.DynamicPortRangeNumberOfPorts -ne 16384
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$tcpPorts | Should -BeNullOrEmpty
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
It "Test UDP dynamicport start=49152 num=16384" {
|
|
|
|
|
$udpPorts = Get-NetUDPSetting | Where-Object {
|
|
|
|
|
$_.DynamicPortRangeStartPort -ne 49152 -or $_.DynamicPortRangeNumberOfPorts -ne 16384
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$udpPorts | Should -BeNullOrEmpty
|
|
|
|
|
}
|
2021-02-24 18:48:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Describe "GDIProcessHandleQuota" {
|
|
|
|
|
It "The GDIProcessHandleQuota value is 20000" {
|
|
|
|
|
$regPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows"
|
|
|
|
|
$regPath32 = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion\Windows"
|
|
|
|
|
(Get-ItemProperty $regPath).GDIProcessHandleQuota | Should -BeExactly 20000
|
|
|
|
|
(Get-ItemProperty $regPath32).GDIProcessHandleQuota | Should -BeExactly 20000
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-09-16 15:58:40 +03:00
|
|
|
|
2022-08-01 15:35:36 +02:00
|
|
|
Describe "Test Signed Drivers" {
|
2023-12-11 22:23:36 +01:00
|
|
|
It "bcdedit testsigning should be Yes" {
|
2021-09-16 15:58:40 +03:00
|
|
|
"$(bcdedit)" | Should -Match "testsigning\s+Yes"
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-11-16 17:14:17 +03:00
|
|
|
|
|
|
|
|
Describe "Windows Updates" {
|
|
|
|
|
It "WindowsUpdateDone.txt should exist" {
|
|
|
|
|
"$env:windir\WindowsUpdateDone.txt" | Should -Exist
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-27 12:29:42 +01:00
|
|
|
$testCases = Get-WindowsUpdateStates | Sort-Object Title | ForEach-Object {
|
2021-11-16 17:14:17 +03:00
|
|
|
@{
|
2023-12-11 22:23:36 +01:00
|
|
|
Title = $_.Title
|
2023-11-27 12:29:42 +01:00
|
|
|
State = $_.State
|
2021-11-16 17:14:17 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
It "<Title>" -TestCases $testCases {
|
2023-11-27 12:29:42 +01:00
|
|
|
$expect = "Installed"
|
2021-11-16 17:14:17 +03:00
|
|
|
if ( $Title -match "Microsoft Defender Antivirus" ) {
|
2023-11-27 12:29:42 +01:00
|
|
|
$expect = "Installed", "Failed", "Running"
|
2021-11-16 17:14:17 +03:00
|
|
|
}
|
|
|
|
|
|
2023-11-27 12:29:42 +01:00
|
|
|
$State | Should -BeIn $expect
|
2021-11-16 17:14:17 +03:00
|
|
|
}
|
|
|
|
|
}
|
2024-12-30 11:11:22 +01:00
|
|
|
|
2025-01-02 15:43:53 +01:00
|
|
|
Describe "WSL2" -Skip:((Test-IsWin19) -or (Test-IsWin22)) {
|
2024-12-30 11:11:22 +01:00
|
|
|
It "WSL status should return zero exit code" {
|
|
|
|
|
"wsl --status" | Should -ReturnZeroExitCode
|
|
|
|
|
}
|
|
|
|
|
}
|