Last active
November 7, 2020 12:19
-
-
Save TomasBouda/14d9946ae96fea0f034fccaf4e231ee4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[Parameter(Mandatory = $false)] | |
[string]$OutFile, | |
[Parameter(Mandatory = $false)] | |
[switch]$HideHost, | |
[Parameter(Mandatory = $false)] | |
[switch]$HideNET, | |
[Parameter(Mandatory = $false)] | |
[switch]$HideNETCore | |
) | |
function Out-Info{ | |
param( | |
[Parameter(Mandatory = $true, ValueFromPipeline = $true)] | |
[AllowEmptyString()] | |
[string]$Data | |
) | |
process{ | |
Write-Host $Data | |
if($null -ne $OutFile -and $OutFile -ne ''){ | |
$Data | Add-Content $OutFile | |
} | |
} | |
} | |
if($null -ne $OutFile -and $OutFile -ne ''){ | |
Remove-Item $OutFile -Force -ErrorAction SilentlyContinue | |
} | |
# PowerShell version | |
$PSVersionTable | Out-String | Out-Info | |
if (-not $HideHost) { | |
# PS Host info | |
Get-Host | Out-String | Out-Info | |
} | |
if (-not $HideNET) { | |
# .NET Framework versions | |
Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse | | |
Get-ItemProperty -Name Version, Release -EA 0 | | |
Where-Object { $_.PSChildName -match '^(?!S)\p{L}' } | | |
Select-Object PSChildName, Version, Release | | |
Out-String | | |
Out-Info | |
} | |
if(-not $HideNETCore){ | |
# .NET Core versions | |
if (Get-Command 'dotnet' -ErrorAction SilentlyContinue) { | |
dotnet --info | Out-Info | |
} | |
else { | |
Write-Output '.NET Core is not installed!' | Out-Info | |
} | |
} |
Author
TomasBouda
commented
Nov 7, 2020
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment