You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Implement a PowerShell cmdlet that returns detailed OS/environment information #419
I've done some work close to this in the PSScriptAnalyzer repo, here, where we collect platform information.
A few points:
CIM/WMI isn't available on all platforms (even some Windows ones, due to lockdown) and isn't terribly fast. In cases where a Windows SKU ID is wanted, there are one or two alternatives.
The uname syscall is very inconvenient to p/invoke since it requires setting inline C-strings (i.e. char arrays) of platform-dependent size on a struct passed in (StackOverflow question discussing this). On Linux, it's much better to read from /proc/sys/kernel. macOS I haven't explored, but hopefully either (1) there's some other reasonable way to access that information, or (2) the size of struct utsname is more reliable
[System.Runtime.InteropServices.RuntimeInformation]::OSDescription might be ok to use on macOS. It's a problem on Linux because it doesn't capture the kernel version fully (if you're on an alternative kernel or patchset, there's no info on that).
The /etc/*-release files are also worth capturing on Linux and are readily parseable as CSV/INI. However, they're not well standardised.
This man page summarises the os-release concept. It's surprisingly involved.
lsb-release is a less formalised standard, but is still widespread. This gist captures variants on many distros
Getting the OS architecture may be harder than it looks because, last time I checked, some of System.Runtime.InteropServices.RuntimeInformation's APIs don't work properly on Win 7 kernels (https://github.com/dotnet/corefx/issues/33885).
@paulbailey1979 if you want to tackle this, I would suggest starting with a RFC detailing what info will be collected (and how) as I'm sure there will be some debate on what information is most critical to collect
The CMDLETS Working Group has reviewed this issue and feels that this is a great candidate for a community module held on the PowerShell Gallery. As such, we are closing this issue as Will Not Implement.
There are some published modules and scripts that already met this requirement. We urge the original poster and others to collaborate on a community module if the existing scripts/modules are not satisfactory.
If there is adequate interest in such a cmdlet, the working group can review this decision.
Activity
andyleejordan commentedon Jan 28, 2016
James Truher (@JamesWTruher) perhaps you could help us figure out how to do this properly. The C# code to determine Linux/Windows/OS X is trivial.
JamesWTruher commentedon Jan 29, 2016
sure - I'll be happy to help with that
palladia commentedon Feb 4, 2016
Need more requirements on this cmdlet...
$os = Get-OperatingSystem
$os | format-list *
Name : Linux
Version : 14.04.1-Ubuntu
???
andyleejordan commentedon Feb 4, 2016
That we do. James Truher (@JamesWTruher) how do you think this cmdlet should work?
JamesWTruher commentedon Feb 4, 2016
Since I doubt that wmi/cim is not available, it should probably reflect uname output (except as an object)
j
From: Andy Schwartzmeyer [mailto:notifications@github.com]
Sent: Thursday, February 4, 2016 1:12 PM
To: PowerShell/PowerShell-Linux PowerShell-Linux@noreply.github.com
Cc: Jim Truher Jim.Truher@microsoft.com
Subject: Re: [PowerShell-Linux] Implement a PowerShell cmdlet that returns the OS (#419)
That we do. @JamesWTruherhttps://github.com/JamesWTruher how do you think this cmdlet should work?
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/419#issuecomment-180051628.
48 remaining items
rjmholt commentedon Jun 3, 2019
Just came across this issue.
I've done some work close to this in the PSScriptAnalyzer repo, here, where we collect platform information.
A few points:
unamesyscall is very inconvenient to p/invoke since it requires setting inline C-strings (i.e. char arrays) of platform-dependent size on a struct passed in (StackOverflow question discussing this). On Linux, it's much better to read from/proc/sys/kernel. macOS I haven't explored, but hopefully either (1) there's some other reasonable way to access that information, or (2) the size ofstruct utsnameis more reliable[System.Runtime.InteropServices.RuntimeInformation]::OSDescriptionmight be ok to use on macOS. It's a problem on Linux because it doesn't capture the kernel version fully (if you're on an alternative kernel or patchset, there's no info on that)./etc/*-releasefiles are also worth capturing on Linux and are readily parseable as CSV/INI. However, they're not well standardised.os-releaseconcept. It's surprisingly involved.lsb-releaseis a less formalised standard, but is still widespread. This gist captures variants on many distrosSystem.Runtime.InteropServices.RuntimeInformation's APIs don't work properly on Win 7 kernels (https://github.com/dotnet/corefx/issues/33885).SteveL-MSFT commentedon Jun 5, 2019
@paulbailey1979 if you want to tackle this, I would suggest starting with a RFC detailing what info will be collected (and how) as I'm sure there will be some debate on what information is most critical to collect
lukeb1961 commentedon Dec 20, 2020
coming up to its fifth birthday...
adityapatwardhan commentedon Feb 25, 2021
We recommend that this should be released to the gallery as a separate module.
rkeithhill commentedon May 19, 2021
FYI, this approach is handy on Linux:
G31st commentedon Jul 8, 2021
Any traction on this ?
lukeb1961 commentedon Jul 14, 2021
I see other people have done interesting things in collating this sort of info.
https://github.com/Jinjinov/Hardware.Info
doctordns commentedon Feb 15, 2022
The CMDLETS Working Group has reviewed this issue and feels that this is a great candidate for a community module held on the PowerShell Gallery. As such, we are closing this issue as Will Not Implement.
There are some published modules and scripts that already met this requirement. We urge the original poster and others to collaborate on a community module if the existing scripts/modules are not satisfactory.
If there is adequate interest in such a cmdlet, the working group can review this decision.
Ilya (@iSazonov) Steve Lee (@SteveL-MSFT) - can one of you please close this formally?