Skip to content

Instantly share code, notes, and snippets.

@TomasBouda
Last active November 7, 2020 12:19
Show Gist options
  • Save TomasBouda/14d9946ae96fea0f034fccaf4e231ee4 to your computer and use it in GitHub Desktop.
Save TomasBouda/14d9946ae96fea0f034fccaf4e231ee4 to your computer and use it in GitHub Desktop.
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
}
}
@TomasBouda
Copy link
Author

TomasBouda commented Nov 7, 2020

iex ((New-Object System.Net.WebClient).DownloadString('https://gist.githubusercontent.com/TomasBouda/14d9946ae96fea0f034fccaf4e231ee4/raw/522efa220c0590a2dcf1fd699a87d0f07ead6ff3/Get-PSInfo.ps1'));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment