I was installing SQL Server 2014 on an Azure server the other day when I remembered that I had not installed the .NET Framework 3.5. Going through the UI is always a pain, so I wondered if it is possible to install using PowerShell… well, I knew it would be, I just wondered how straight forward it would be. Turns out it's very straightforward!

Install-WindowsFeature -name NET-Framework-Core

It's also possible to check the whether .NET is installed or not.

Get-WindowsFeature -name NET-Framework-Core

And finally, you can remove the feature easily enough

Remove-WindowsFeature -name NET-Framework-Core

And because I like to automate tedious tasks, I created a PowerShell script to check and install .NET if it is not installed, or just ignore it if it is already installed. I know the script uses write-host to write the output directly to the console, and I should use write-output, but I like write-host because reasons.

$b = Get-WindowsFeature -name NET-Framework-Core | Format-Table Installed -HideTableHeaders | Out-String
$b = $b.Trim()
if ($b -eq "True") 
	{
	write-host ".Net 3.5 is already installed"
	} 
else 
	{
	write-host ".Net 3.5 is not installed. Installing..."
	Install-WindowsFeature -name NET-Framework-Core
	}

Far quicker and simpler than going through the UI.