Skip to content

Instantly share code, notes, and snippets.

@aaronk1
aaronk1 / get_powershell_version.ps1
Last active November 22, 2016 22:40
get_powershell_version.ps1
# Supports Windows 2012 R2 and up. Ensure you have Local Administrator access and network connectivity to the target servers for whatever account runs this.
Function ConfirmState
{
param($confirm_feature,$truetext,$falsetext)
if($truetext -eq $null){$truetext = "$confirm_feature was successfully installed!"}
if($falsetext -eq $null){$falsetext = "ERROR!!! $confirm_feature was NOT INSTALLED!"}
$installstate = Get-WindowsOptionalFeature -Online -FeatureName $confirm_feature
if($installstate.state -Like "Enabled"){$truetext| %{ Write-Host -foreground "green" $_; $_ } | Out-File $log_file -Append}else{$falsetext | %{ Write-Host -foreground "red" $_; $_ } | Out-File $log_file -Append}
}