The Windows registry stores the names and details of all software that you installed. PowerShell can read this information and provide you with a complete software inventory:
# read all child keys (*) from all four locations and do not emit
# errors if one of these keys does not exist
It’s important to check every now and then that your PowerShell modules are up-to-date. If you are using old and outdated modules, you can run into issues, just like using old and outdated software in general.
For example, the PowerShellGet module provides cmdlets like Install-Module that let you…
PowerShell is just a scripting platform and can be extended with new commands. A great source for new commands is the public PowerShell Gallery. You can visit the graphical front-end at https://powershellgallery.com and search for modules.
PowerShell comes with a module called PowerShellGet which in…
WMI is extremely powerful but a little underdocumented. To change this, a group has formed and is creating a PowerShell-specific WMI reference: https://powershell.one/wmi
To easily look up help, you can add the Help() method to all of your WMI and CIM instance objects. Simply run this code:
In Windows 10 and Server 2016, WMI added a new property that simplifies collecting chassis or enclosure SKUs. This one-liner reads the SKU for you:
PS> Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object -Property Name, ChassisSKUNumber
When a Windows system crashes, it typically reboots immediately. This is called “Automatic Reset Capability”, and with this one-liner you can check whether your machine supports it:
Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object -Property Name, AutomaticResetCapability
Beginning in PowerShell 5, you can create your own attributes, i.e. custom validators. They can be applied to variables (and parameters), and once a value is assigned that does not match the validator, an exception is raised.
Here is an example for a path validator. When you apply it to a variable, only…
Ever needed to know whether you are currently connected to a metered (costly) network? Here is a quick way to check:
[void][Windows.Networking.Connectivity.NetworkInformation, Windows, ContentType = WindowsRuntime]
$cost = [Windows.Networking.Connectivity.NetworkInfor…
In the previous tip we showed that the new Get-CimInstance command is missing the important “__Path” property that was returned by Get-WmiObject. Let’s add this property back to Get-CimInstance.
Every instance returned by Get-CimInstance is of type [Microsoft.Management.Infrastructure…
Generally, it is the best to move away from the old and deprecated Get-WmiObject command and instead use the modern and faster CIM cmdlets like Get-CimInstance. In most scenarios, they almost work the same.
In a few areas, though, the new CIM cmdlets lack information. One of the most important areas…
Powered by IDERA