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. […]
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 […]
Iterate a shared network folder to look into domain users or security group permissions
The Get-Acl cmdlet can help us to obtain the access control list of a resource, for example a directory. With this information we can determine the permissions that a domain user or a security group has over a resource. Let’s check the help for this command: The Get-Help shows three different sets of parameters for […]
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 […]