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 […]
Create a new Windows Domain with Ansible using the win_powershell module
In this entry, we are going to use Ansible to manage a Windows host. To create a control node, the machine that is going to run Ansible, you have to use a UNIX-like system. This opens the possibility to use the Windows Subsystem for Linux if an independent control node is not an option for […]
A bash script to generate random passwords
There is a couple of ways to create a random password with shell/bash. For instance, we can just pipe the date command to md5sum or sha256sum to generate a seemingly random string that can be used as a password: That is a start. If we don’t want the whole string, when can trim the result […]
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. […]