When you run Get-Credential or are otherwise prompted for a username and password, Windows PowerShell (powershell.exe) always opens a separate credentials dialog. The new PowerShell 7 (pwsh.exe) prompts inside the console:
PowerShell credential request
Enter your credentials.
The official PowerShell Gallery is a public repository with thousands of free PowerShell modules. Instead of reinventing the wheel, it makes total sense to browse the gallery for reusable code that you can use as-is or as a starting point for your own projects. Let’s take a look at how you can discover…
If you use SharePoint Online and would like to manage it via PowerShell, download and install the Microsoft.Online.SharePoint.PowerShell module from the PowerShell Gallery:
# search for the module in PowerShell Gallery (optional)
PS> Find-Module -Name Microsoft.Online.SharePoint.PowerShell
When you want to submit sensitive information to a PowerShell function, you typically use the SecureString type. This type makes sure a user gets prompted with a masked dialog box, and the input is protected from anyone “looking over the shoulder”.
Since SecureString can always be decrypted…
Passwords are no longer considered safe when they are complex. Instead, you need to ensure that passwords have not been compromised and are not part of default attacker dictionaries. Even the most complex password is unsafe if it is routinely checked by automated attacks.
To find out whether a password…
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
Powered by IDERA