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 […]
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 […]
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. […]
Custom columns and table entries with Format-Table
Sometimes objects in PS don’t have a descriptive property name or the information of an object could use a little bit of formatting to better fit our purposes. Take for example the VirtualMemorySize64 property of the processes running on Windows: That’s a big number. We can dig a bit further to check its type to […]
Moving users or computers in AD with the Move-ADObject cmdlet
According to the official documentation, Move-ADObject “Moves an Active Directory object or a container of objects to a different container or domain”. The straightforward noun-verb structure of PS also suggest what you can do with it. Let’s review the syntax: Both -Identity and -TargetPath are obligatory parameters. Regarding -Identity, we can use a distinguished name […]
Checking and comparing user AD group membership
In the AD module for PS there’s an easy cmdlet that allow us to check the groups a user is member of. We’re talking about Get-ADPrincipalGroupMemberShip. Let’s check the sintaxis: Interpreting the sintaxis, we are able to conclude the following: Because “-Identity” parameter and value “<ADPrincipal>” aren’t enclosed in square brackets we know is mandatory. […]