Use PowerShell to log logon and logoff activity on domain computers

There are many ways to log user activity on a domain. One of the ways that I prefer is to write user logon and logoff activity to plain text files on a network share. I used to do this via a .bat file, but recently rewrote the process using PowerShell. Create a Shared Folder for …

Remove spaces from column names when using PowerShell’s Import-Csv

When using PowerShell’s Import-Csv cmdlet, it is ideal for the column headings in the source file to not have any spaces. While the import will work, later referencing values in each column heading is messy. Let me demonstrate. Messy Column Headers with spaces Let’s say your source file looks like this. Note that there are …

Using PowerShell to clean up DHCP and DNS for VDI

When you run a virtual desktop infrastructure that builds and deletes hundreds of virtual machines every day, DHCP and DNS might eventually get out of sync and need some cleanup. When writing this PowerShell cleanup script, I decided to make vCenter my source of truth because has the virtual machine host names, IP addresses, power …

Use PowerShell to randomly stagger Veeam backup schedules

In previous posts “Randomize your Veeam backups via PowerShell” and “Fixing Veeam Backup v8 Periodic Scheduling” I discussed the unwanted and unexpected changes Veeam Backup and Replication 8 made to is Periodic Scheduling. In summary, Periodic Schedules could no longer exceed a 24-hour period (e.g. you could no longer configure jobs to run every 30 …

PowerShell Get-Date formatting

I sometimes use PowerShell to create files or logs that include the date or time. My preference is to write dates and times from greatest to smallest value. I also prefer to use the hyphen as a delimiter because it is filename friendly. Here are the three most frequently used Get-Date -Format specifiers that I …