Creating Screenshots with PowerShell
If you want to create screenshots with PowerShell, then you need to use .NET. I will show you the required code below. But if you want to do it easier, you can also use my Screenshot PowerShell module (more information on that further down). I also demonstrate the following options in this video on YouTube. Why though? Of course, screenshots can simply be created manually by pressing the [Print] key on your keyboard, and there are also good tools for editing screenshots (for example Greenshot). But if you already automate something with PowerShell then it can be helpful e.g. for documentation purposes, if you can create screenshots automatically. ...

Find out which Process is listening on a Port using PowerShell
If you want to find out which process is listening on a specific TCP/UDP port, you can also use PowerShell for this in Windows. I find this easier than analyzing the output of netstat. I also show this in a Video on YouTube. For TCP: Get-NetTCPConnection For TCP connections, there is the Get-NetTCPConnection cmdlet. However, it only returns the ID of the running process (the OwningProcess property), but we can resolve that using Get-Process. Manually, you would do it like this: ...
Unraid: Cannot destroy '<Share Name>': dataset is busy
I recently had an issue on my Unraid server: I wanted to delete a share (“myshare”) via the GUI, but it just did not do it. When I checked the logs, I found the following: 1 2 3 4 5 6 7 Dec 27 21:53:24 tower emhttpd: readlink -e '/mnt/user/myshare' Dec 27 21:53:24 tower emhttpd: /mnt/user/myshare Dec 27 21:53:24 tower emhttpd: shcmd (750): rmdir '/mnt/user/myshare' Dec 27 21:53:24 tower shfs: /usr/sbin/zfs unmount 'cache/myshare' 2>&1 Dec 27 21:53:24 tower shfs: /usr/sbin/zfs destroy 'cache/myshare' 2>&1 Dec 27 21:53:24 tower shfs: cannot destroy 'cache/myshare': dataset is busy Dec 27 21:53:24 tower shfs: /usr/sbin/zfs mount 'cache/myshare' 2>&1 So apparently the dataset is busy 😐… Weird, because it’s completely empty and no Containers or VMs are supposed to use the share. The hints that I found on the Internet did not help me: ...
Add leading zeros with PowerShell
There are many different ways to add leading zeros to a number in PowerShell. In practice, numbers (object type: [int]) cannot have leading zeros, so we are really creating a text value (object type: [string]) that contains the number. In the examples below, I pad the number 42 to four digits (0042). Of course, you can adjust the length of the padding as needed :) I also demonstrate the following options (and a few more) in this video on YouTube. ...
Enable, configure, and restore objects from the Active Directory Recycle Bin
If you use Active Directory Domain Services, you should definitely check whether the AD Recycle Bin is enabled in your environment. What is the AD Recycle Bin? The AD Recycle Bin works similarly to the Recycle Bin in the file system: Deleted objects (users, groups, and so on) are first moved to the Recycle Bin and can be restored easily. This is especially useful for: accidental deletions intentional deletions that need to be undone missing AD backups (which do not replace a backup) The AD Recycle Bin was introduced with Windows Server 2008 R2. Requirement: your AD forest must have at least the Windows Server 2008 R2 functional level. ...
Send emails with PowerShell and Microsoft Graph
Sending emails via PowerShell and the Microsoft Graph API is unfortunately not as simple as with the classic Send-MailMessage cmdlet. I also recently published a blog post about the classic approach. Nevertheless, there are several reasons to prefer sending mail via Microsoft Graph. In October 2025, plaintext authentication (Basic Authentication) for SMTP sending in Exchange Online is expected to be turned off. So if Exchange Online is your only email system, but you want to send emails automatically, MS Graph is the right choice. Alternatively, of course, you could also purchase (or host) an additional email system. ...
Send emails with PowerShell using Send-MailMessage
It is fairly easy to send emails with PowerShell. For that purpose, there is the built-in cmdlet Send-MailMessage, which Microsoft now describes as deprecated: ⚠️ Warning The Send-MailMessage cmdlet is deprecated. This cmdlet does not guarantee secure connections with SMTP servers. Although there is no immediate replacement available in PowerShell, it is recommended not to use Send-MailMessage. For more information, see Platform Compatibility Note DE0005. Source: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/send-mailmessage?view=powershell-7.5 For some scenarios, using Send-MailMessage is still okay in my opinion. For example, if you run your own SMTP server, such as a Microsoft Exchange Server, or you have one hosted somewhere else, there is often no support for modern authentication methods. Of course, you could also run such an SMTP server in addition to an Exchange Online environment. In general, I would recommend using a subdomain such as “reports.demotenant.de” rather than just “demotenant.de” for these automated emails, but that is not a requirement. ...
Entra Connect: Soft Match and Hard Match
In this post, I will explain how Entra Connect merges identities and then continues to track them in operation. Some points could be explored in more depth, but these are the most important fundamentals in my opinion. Everything I describe here is usually relevant for both classic Entra Connect Sync and the newer Entra Cloud Sync. If something only applies to one of the two sync tools, I will point that out explicitly. Otherwise, for simplicity, I will just write Entra Connect below when I mean both. ...
Retrieve infos about Active Directory Based Activation via PowerShell
If you quickly want to retrieve infos about Active Directory Based Activation (ADBA) in your domain, you can use this PowerShell One-liner: 1 Get-ADDomain | %{Get-ADObject -SearchBase "CN=Activation Objects,CN=Microsoft SPP,CN=Services,CN=Configuration,$($_.DistinguishedName)" -LDAPFilter "(objectclass=msspp-activationobject)" -Properties * -ErrorAction SilentlyContinue | fl displayName,DistinguishedName,Name,msspp-csvlkpartialproductkey } I haven’t tested it in a multi-domain environment, but I think it should work. Explanation The code uses aliases, which are not great in scripts, but neat in One-Liners. It uses Get-ADDomain to determine the Distinguished Name for the Domain. This should make the code portable. ...
PowerShell: Cancel and Skip Loops Intentionally
Normally, a loop in PowerShell runs as long as it is defined by the condition block outside it. For example, the following while loop runs as long as the variable named $Variable is less than or equal to 10. 1 2 3 while($Variable -le 10) { # something } However, it is also possible to terminate a complete loop early or skip a single loop iteration on purpose. This also works when you have multiple loops nested inside each other. ...