PowerShell

Simplifying Unix Epoch Timestamps in PowerShell Using DateTimeOffset

Simplifying Unix Epoch Timestamps in PowerShell Using DateTimeOffset

Handling Unix Epoch timestamps in PowerShell can be cumbersome, but with DateTimeOffset, you can streamline conversions with minimal effort.

If you’ve ever dealt with Unix Epoch time in PowerShell, you know it can be a hassle. By default, Get-Date doesn’t output or accept Epoch time, forcing users to manually calculate the seconds between 1970 and their target date. PS C:\> # Examples of Previous ways to calculate current Unix Time PS C:\> [int][double]::Parse((Get-Date -UFormat %s)) 1724142672 PS C:\> [System.Math]::Truncate((Get-Date -UFormat %s)) 1724142720 Fortunately, there’s a better way. The .NET DateTimeOffset class provides an efficient method to handle Unix Epoch timestamps directly in PowerShell.
Veeam Quick Backup with PowerShell

Veeam Quick Backup with PowerShell

Discover how to effortlessly safeguard your VMs with Veeam's Quick Backup using PowerShell. Learn the benefits, prerequisites, and step-by-step instructions to ensure reliable recovery points and seamless integration into your backup strategy.

Introduction In today’s fast-paced IT environment, maintaining up-to-date backups is crucial for data protection and disaster recovery. Veeam Quick Backup functionality offers a streamlined solution for efficiently backing up individual VMs or groups of VMs. This feature is designed to be quick and user-friendly, making it an excellent tool for system administrators who need to perform ad-hoc backups without disrupting their regular backup schedules. In this blog post, we’ll delve into the Quick Backup feature, focusing on how to leverage it using PowerShell.

Testing DFS Replication with Powershell

DFS Replication (DFS-R) is a fantastic tool in any sysadmins belt when it comes to creating highly redundant and scalable file shares. And yet anyone who has used it, knows that monitoring it can be difficult at the best of times. Windows Server 2012 introduced several Powershell commands for DFS-R which help discover partnerships and their status, however none of them test replication end-to-end. So here are the goals I get out to achieve with Powershell:

Updating your AzureStack? Make sure you don't miss any steps!

AzureStack is a fantastic appliance, with a massively simplified patch and lifecycle policy thanks to a lot of hard work from Microsoft and the OEMs delivering it. But even with all that, to ensure the best experience when updating AzureStack, you should always apply the available hotfixes in-between updates. At some point, you may find you’ve fallen more than one update behind and need to catch up. Finding all the right hotfixes and updates requires reading each of the release notes for prerequisites.

Perform better Storage Spaces Direct maintenance with these Powershell functions

Storage Spaces Direct (S2D) is an incredibly powerful technology, and makes up a huge part of the new AzureStack HCI Solution, however performing maintenance on it can catch out new players. One of the biggest causes of failures while performing maintenance on S2D hosts and clusters, is that the hosts haven’t been correctly put into maintenance mode, so I set out to simplify the process with 3 new functions. The 3 activities I’ve targeted with these functions are enabling and disabling maintenance mode on a host correctly, and checking the current state of a host or cluster.

Installing Azure Monitor Log Analytics Agents with Powershell

After my previous article about the wonders of the new Azure Update Management Extension for SCVMM 2019, some of you might have been thinking that it was all well and good that VMM now automates the installation and configuration of the Azure Monitor Log Analytics Agent (MMA) for you when deploying new VMs, but what about all those existing servers out there? Well unfortunately out of the box, Microsoft doesn’t provide a single installer UI that can target multiple machines, unless you’ve also got SCOM deployed and have configured it’s OMS integration as well.

Adding WhatIf and Confirm Parameters to your Powershell

One of the handy functions built into Powershell, is the ability to preview what would happen if you run a command. This could be as simple as wanting to make sure that your Remove-Item actually deletes the write files, or that Set-ADUser changes the right attribute. Hand in hand with -WhatIf is -Confirm, it will prompt you for high risk actions and confirm if you really want to perform the action, like deleting an AD user account.

Get a pretty view of your S2D Storage Pools

I’d like to start with a shout out to Philip Elder, for he came up with the initial idea and script that I’ve used here. One thing that’s not always obvious when dealing with S2D Clusters is how much of your Storage Pool has been provisioned and how much capacity, if any, is left. To help with this, we came up with be script you’ll see at the bottom of this article.

Looking at the Write Cache in Storage Spaces Direct

If you’ve ever dealt with a SAN or Storage guy before, you’ll know that they usually have a huge passion for cache stats. This is because the secret sauce of accelerating cheap storage for years has been to stick a small amount of expensive but super fast flash in front of your slower spinning disk, or in recent years, your cheaper low endurance SSDs. Because of this, it was always a good idea to keep an eye on how your cache was going, making sure things like Cache Hit Misses were low, and that your Write Cache wasn’t overallocated.

You need to change the way you patch S2D Clusters

If you’re running a Storage Spaces Direct (S2D) Cluster, you might have noticed some instability in recent months, specifically when it comes to patching and performing maintenance. Well you’re in luck because 5 days ago, Microsoft released a new KB article that helps explain why you might have seen issues. The scenario targeted by the Microsoft article is S2D Clusters running May (KB4103723) or later patch levels, where you experience Event ID 5120 during patching or maintenance, leading to things like CSV timeouts, VM pauses, or even VM crashes.