Files
windows-install/DSC-WindowsFeatures.ps1
EzekialSA 79df17763a Add DSC configurations for user interface, Windows features, and services; implement app installation and removal scripts
- Created `DSC-UserInterfaceConfiguration.ps1` to manage user interface settings via registry changes.
- Developed `DSC-WindowsFeatures.ps1` to install OpenSSH Client and enable NFS Client features.
- Implemented `DSC-WindowsServices.ps1` to ensure Terminal Services are running and set to automatic startup.
- Added `PS-InstallApps.ps1` to manage app installations and remove the msstore source if it exists.
- Created `PS-RemoveApps.ps1` to remove unwanted apps, provisioned packages, and handle Office applications via winget.
2025-09-28 11:59:28 -05:00

88 lines
3.6 KiB
PowerShell

Configuration WindowsFeatures {
Import-DscResource -ModuleName PSDesiredStateConfiguration
Node localhost {
# === WINDOWS CAPABILITIES ===
# Install OpenSSH Client
Script InstallOpenSSHClient {
SetScript = {
$capability = Get-WindowsCapability -Online | Where-Object { $_.Name -like "OpenSSH.Client*" }
if ($capability.State -ne "Installed") {
Add-WindowsCapability -Online -Name 'OpenSSH.Client~~~~0.0.1.0'
}
}
TestScript = {
$capability = Get-WindowsCapability -Online | Where-Object { $_.Name -like "OpenSSH.Client*" }
return ($capability.State -eq "Installed")
}
GetScript = {
$capability = Get-WindowsCapability -Online | Where-Object { $_.Name -like "OpenSSH.Client*" }
return @{Result = "OpenSSH Client State: $($capability.State)"}
}
}
# === WINDOWS OPTIONAL FEATURES ===
# Enable NFS Client features
Script EnableNFSClientOnly {
SetScript = {
$feature = Get-WindowsOptionalFeature -Online -FeatureName "ServicesForNFS-ClientOnly"
if ($feature.State -ne "Enabled") {
Enable-WindowsOptionalFeature -FeatureName "ServicesForNFS-ClientOnly" -Online -NoRestart
}
}
TestScript = {
$feature = Get-WindowsOptionalFeature -Online -FeatureName "ServicesForNFS-ClientOnly"
return ($feature.State -eq "Enabled")
}
GetScript = {
$feature = Get-WindowsOptionalFeature -Online -FeatureName "ServicesForNFS-ClientOnly"
return @{Result = "NFS ClientOnly State: $($feature.State)"}
}
}
Script EnableNFSInfrastructure {
SetScript = {
$feature = Get-WindowsOptionalFeature -Online -FeatureName "ClientForNFS-Infrastructure"
if ($feature.State -ne "Enabled") {
Enable-WindowsOptionalFeature -FeatureName "ClientForNFS-Infrastructure" -Online -NoRestart
}
}
TestScript = {
$feature = Get-WindowsOptionalFeature -Online -FeatureName "ClientForNFS-Infrastructure"
return ($feature.State -eq "Enabled")
}
GetScript = {
$feature = Get-WindowsOptionalFeature -Online -FeatureName "ClientForNFS-Infrastructure"
return @{Result = "NFS Infrastructure State: $($feature.State)"}
}
}
# === FIREWALL RULES ===
# Enable Remote Desktop firewall rules
Script EnableRDPFirewall {
SetScript = {
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
}
TestScript = {
$rules = Get-NetFirewallRule -DisplayGroup "Remote Desktop" | Where-Object {$_.Enabled -eq $false}
return ($rules.Count -eq 0)
}
GetScript = {
$rules = Get-NetFirewallRule -DisplayGroup "Remote Desktop"
$enabledCount = ($rules | Where-Object {$_.Enabled -eq $true}).Count
return @{Result = "RDP Firewall Rules Enabled: $enabledCount of $($rules.Count)"}
}
}
}
}
# Generate the MOF file
WindowsFeatures -OutputPath "\temp\DSC\WindowsFeatures"
# Apply the configuration
Start-DscConfiguration -Path "\temp\DSC\WindowsFeatures" -Wait -Verbose -Force