Since PowerShell Core 6, PowerShell became cross-platform, free and open source. There is, of course, some limitations when it comes to PowerShell for non-Windows platforms. Microsoft documentation explains that: “PowerShell on Linux and macOS uses .NET Core, which is a subset of the full .NET Framework on Microsoft Windows. As a result, scripts that run […]
Automatically elevate a Powershell session
By default, recent versions of Windows ship with something called User Account Control (UAC). Because of this, “standard users and administrators access resources and run apps in the security context of standard users”. For this to work Windows creates two different types of tokens based on the user privileges: Standard user access token Administrator access […]
Programmatically switch between audio devices in Windows
Recent versions of Windows offer simple ways to change your default audio devices to play or record sounds. In the case of Windows 10, that option is conveniently located in the task bar. But what if you want to automatically change the audio device? Manage your audio devices from PowerShell with AudioDeviceCmdlets AudioDeviceCmdlets is a […]
Use CSS to style HTML reports in PowerShell
ConvertTo-HTML allows to add all kind of different elements into an HTML file. HTML files have a simple structure that usually include a head and a body. Those elements can be modified with ConvertTo-HTML parameters. Let us check the syntax of this cmdlet first (this cmdlet has two sets of parameters, we are using the […]
Encrypting data with a key in PowerShell
If you need to encrypt text in your PowerShell code, ConvertFrom-SecureString can help you do it. The -Key parameter of that cmdlet allows you to use a key that can be stored in a file. This could be useful if you don’t want to have sensitive information in plain text in your code. Let us […]
Creating your own objects with PSCustomObject
PSCustomObject offers us an excellent way to create structured data in PowerShell. According to the documentation, [pscustomobject] is a type accelerator. Type accelerators “allow you to access specific .NET framework classes without having to explicitly type the entire class name”. The full class name for PSCustomObject is System.Management.Automation.PSObject, which means PSCustomObject is just an alias […]
Add one or more users to one or more security groups in Active Directory
I have covered this topic in a previous post, but in that occasion I only explained how to add one or more users to a single group. Sometimes you have different requirements, and it could be useful to be able to add one or more users to one or more groups with the same script. […]