• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Clatent

Technology | Fitness | Food

  • About
  • Resources
  • Contact

Windows

If Maester couldn’t get any better…Custom Test Collection now available

January 27, 2025 by ClaytonT Leave a Comment

The time has finally come. I have created a public repository to store custom Maester tests for everyone. As well as a website for deeper understanding where needed. I haven’t seen anyone else do it yet, and worse case scenario, people can just use the ones that I create, but I envision others adding theirs to this too. Yes, you will have to create the function, test, and the markdown file (I and/or others can help), so that we can have a collection of tests that anyone can pick and choose which ones they want to add to their Maester and customize it to their needs. They don’t need to be 365 related either, as they could be checks for Windows 11 settings, server configs, or check that a certain OU should only has these mentioned users or computers and to make sure that doesn’t change.

This is still in its early stages and would love any feedback to make it better while still showing that it is a companion to Maester. I wanted to get the framework started to that we can start gaining the benefits from the repository while still making it easy to use.

I hope you are excited about this as I am, and we can create a large community collection of tests.

Please star and share the repo. Open issues for tests that you want to see and if you already have one or can make it, put that in the issue. Let’s make all our IT lives easier and safer.

Thank you for taking the time to read this and hope you find value in this and can share your knowledge as well.

Website: https://devclate.github.io/Custom-Maester-Tests/
GitHub: https://github.com/DevClate/Custom-Maester-Tests

I’m also working on a module for the Entra attribute fields that will fix any issues by either manually typing in the correct value or only allow company standard values.

Tagged With: 365, AD, Automation, Entra, Maester, PowerShell, Reporting, Windows Server

Getting Started with 365AutomatedLab Part 1

September 29, 2023 by ClaytonT 2 Comments

Adding/Removing Users

Adding Users

With 365AutomatedLab, you can add as many users with their primary licensing as you need at one time. Currently, the Microsoft Dev Environment only allows 25 licensed users, and one is your primary account, so the max I’d recommend creating is 24 users if you’ll only be using this in a dev environment.

Quickest way to get started is by opening the 365DataEnvironment Excel Workbook in the LabSources folder. Here you can see the formatting for the cells so that a user can be added. (Let me know if you would like more attributes added, as these are required and ones I felt would be most useful to start)

View of 365DataEnvinronment.xlsx

FirstNameLastNameUserNameTitleDepartmentStreetAddressCityStatePostalCodeCountryPhoneNumberMobilePhoneUsageLocationLicense
AliceJohnsonajohnsonIT SpecialistIT1818 Maple StAlbanyNY12207USA212-555-1234212-555-5678USDEVELOPERPACK_E5

If you want to use “real” data, I’d recommend exporting your users from your production environment that you want to test, which you can use “Export-CT365ProdUserToExcel” to do this if you don’t already have a script to do so. You will have to copy the information into the 365DataEnvironment.xlsx, as the export as of right now is using Microsoft default column headers and I need to change them to match the excel sheets.

Now that you have your data all set, it’s time to add them to your Dev tenant.

New-CT365User -FilePath "C:\\Path\\to\\file.xlsx" -domain "contoso.com"

The file path is exactly what it says and you are required to type out the .xlsx or it will fail. The domain will be the domain for your tenant, if its a dev tenant it should be domainname.onmicrosoft.com. Then it will ask you to type in a password that you will user for all users.

That’s it, now you have created all your users.

Deleting Users

Now say you are done testing with those users and you want to remove them, or something you were testing changed their information too much from their original state? All you need is this line of code, and they will all be removed.

Remove-CT365User -FilePath "C:\\Path\\to\\file.xlsx" -Domain "contoso.com"

After the magic of PowerShell happens, all those users will be gone. Nice and easy, right?

Summary

Hope you found this useful, as it has saved me many times/hours when testing different scripts and changing the source data too much, then having to remember the users information to delete. I was surprised when I hadn’t seen anything like this as I know there are so many people testing in 365, and why not make it easier? Please look out for the next part of this series where you’ll be able to add and remove all the different types of groups in 365.

As always feel free to reach out anytime, and let me know what you think as well! Have a great day!

365AutomatedLab

Tagged With: 365, 365AutomatedLab, Automation, MsGraph, PowerShell

Quick Use of OpenAI – End Processes

September 27, 2023 by ClaytonT Leave a Comment

Here is a quick use of OpenAI / ChatGPT to remove Windows processes. If it doesn’t get it right the first time, it usually is a good enough base to only need an edit or 2 for simpler scripts. Not bad for going 2/2 on no edits needed!

PROMPT 1:

Me:

You are a powershell expert, can you write me a script to find all processes running then show me them in a window and I can select which ones I want to delete?

ChatGPT:

Certainly! Here’s a PowerShell script that will retrieve all running processes, display them in a GUI window using Out-GridView, and then terminate the selected processes:


# Get all running processes
$processes = Get-Process | Select-Object Id, Name, CPU, Path

# Display processes in a GridView for selection
$selectedProcesses = $processes | Out-GridView -Title "Select processes to terminate" -PassThru

# Terminate selected processes
$selectedProcesses | ForEach-Object {
    try {
        Stop-Process -Id $_.Id -Force
        Write-Host "Terminated process: $($_.Name) with ID: $($_.Id)"
    } catch {
        Write-Warning "Failed to terminate process: $($_.Name) with ID: $($_.Id)"
    }
}

Steps:

  1. The script fetches all running processes and selects a few useful properties like Id, Name, CPU, and Path.
  2. The processes are then presented in a GridView window using Out-GridView. You can select multiple processes by holding down the Ctrl key and clicking on them.
  3. After you click “OK”, the script will attempt to terminate the selected processes.

Note: Ensure you have the required permissions to terminate processes. Also, be cautious about which processes you terminate, as some are essential for the proper functioning of your system.

Review 1:

You can see that it created the first prompt perfectly, and no edits were necessary.

Selected the processes and gave me a GUI to delete the ones I don’t need anymore

PROMPT 2:

ME:

Can you make it so I can select which one I want see beween ram and cpu?

ChatGPT:

Of course! We can add an initial prompt to let you select between viewing processes based on RAM or CPU usage.

Here’s the updated script:


# Get all running processes
$processes = Get-Process | Select-Object Id, Name, CPU, WS

# Prompt the user to choose between CPU and RAM
$choice = $host.ui.PromptForChoice("Selection", "Choose the metric to display top 5 processes:", @("CPU", "RAM"), 0)

# Display the top 5 processes based on the selected metric
if ($choice -eq 0) {
    $topProcesses = $processes | Sort-Object CPU -Descending | Select-Object -First 5
} else {
    $topProcesses = $processes | Sort-Object WS -Descending | Select-Object -First 5
}

# Display processes in a GridView for selection
$selectedProcesses = $topProcesses | Out-GridView -Title "Select processes to terminate" -PassThru

# Terminate selected processes
$selectedProcesses | ForEach-Object {
    try {
        Stop-Process -Id $_.Id -Force
        Write-Host "Terminated process: $($_.Name) with ID: $($_.Id)"
    } catch {
        Write-Warning "Failed to terminate process: $($_.Name) with ID: $($_.Id)"
    }
}

Now, when you run the script, it will first prompt you to choose between CPU and RAM. After you make your selection, it will display the top 5 processes based on that metric. You can then select which processes you want to terminate.

Review 2:

As you can see this worked exactly how I wanted it to and gave me the option to pick the top 5 highest of ram or cpu usage, then allowed me to delete.

Tagged With: Automation, PowerShell, Windows, Windows Server

Read-Only Friday August 4, 2023 End Of Life Server 2012R2 and managing EOL

August 4, 2023 by ClaytonT Leave a Comment

Read-Only Friday August 4, 2023

Do you still have any Windows Server 2012R2 or earlier in production? This is a friendly reminder that they will be going End Of Life October 10 of this year. If you do have any in production, what is your plan to decommission them? Do you still need the server, or will you be spinning up a new upgraded VM? Do you have the licensing to upgrade? What are your next steps?

Talking about End Of Life, how do you manage and track your equipment and licensing for this scenario? Do you have special asset/license management software, SharePoint list, SQL Database, Excel workbook, or even a csv with dates and costs?

If you’ve made it this far, I’m hoping this isn’t a surprise and this is only a reminder to keep following your plan, but if this is the first time you’re hearing this, please look at this now and put a plan in place, especially if you will need to purchase new licensing. While you are at it, I’d check those servers running 2012R2 and see how much of the services you really need running now, as a lot has probably changed since you first put them into production. Also, do you have enough resources to run both at the same time, or do you have to take a current backup(test to make sure the backup works), delete(or turn off and hope you don’t accidently turn it on while new server is on) your current 2012R2, then build the new on?

Good luck with your migrations and as always if there is anyway I can help, feel free to reach out! Have a great Friday, and remember no unscheduled changes today.

Tagged With: Automation, Documentation, PowerShell, Read-Only Friday, Reporting, Windows Server

Module Monday July 31, 2023

July 31, 2023 by ClaytonT Leave a Comment

Well, here it is!  Module Monday, but this one is a module I’ve been working on for a bit and figured it’s time to put it out to the community for others to enjoy and improve. Have you had to test PowerShell scripts on your 365 tenant and really didn’t want to use your production environment, but wanted to keep the close as possible for testing accuracy? Then you’ll want 365AutomatedLab in your tool chest. It can also be used to add multiple users to an environment from an excel sheet or add multiple groups to a user per their title from an excel sheet. Hope you check it out and leave some feedback! So much I want to do with it and super excited about this project that I feel can help so many!

I’ll be doing some blog posts and video tutorials in the near future. Any preferences?

Thanks to Andrew Pla for the extra push 😆

https://github.com/DevClate/365AutomatedLab

Tagged With: 365, AD, Automation, Documentation, Module Monday, PowerShell

One-Liner Wednesday July 26, 2023

July 26, 2023 by ClaytonT 1 Comment

Ever needed to check a computer or server and see how much disk space is being used? It could be for multiple reasons such as are any disks too low on space, too much available space assigned(think VMs where you need storage for a new server, but assume all of your storage is tied up), or you just need to see drives that have more than a certain amount of free space due to company standards.

This little one-liner is a great template for you then. This one liner will show any drive on the current computer that has more than 30gb of space free. You could easily change the “-gt” to “-lt” and only show drives with less than 30gb of space free.

Get-PSDrive -PSProvider 'FileSystem' | Where-Object { ($_.Free / 1GB) -gt 30 } | Format-Table -AutoSize

I know your thinking, I can easily click on my computer and check hard drive space, but what about if you have 10, 100, or 1000+ devices you have to manage? Do you really want to do all of those clicks? You could even set this up as a scheduled task and have it notify you, send to teams/discord/etc, or even email a Distribution List with a report. That sounds like a lot better idea than wasting time clicking around.

If your curious on how to have this capture multiple computers, one way is:

$Computers = 'Computer1', 'Computer2', 'Computer3'  # Replace with your computer names or IPs

$ScriptBlock = {
    Get-PSDrive -PSProvider 'FileSystem' | 
    Where-Object { ($_.Free / 1GB) -gt 30 } | 
    Format-Table -AutoSize
}

foreach ($Computer in $Computers) {
    Invoke-Command -ComputerName $Computer -ScriptBlock $ScriptBlock
}

I hope you found this one-liner useful, and would love to hear how you use it or have used it in the past! And as always if you have any questions, please feel free to reach out and if I can’t help you out, and I can find someone that can.

Tagged With: Automation, Disk Usage, One Liner Wednesday, PowerShell, Reporting, Windows Server

  • Page 1
  • Page 2
  • Page 3
  • Go to Next Page »

Primary Sidebar

Clayton Tyger

Tech enthusiast dad who has lost 100lbs and now sometimes has crazy running/biking ideas. Read More…

Find Me On

  • Email
  • GitHub
  • Instagram
  • LinkedIn
  • Twitter

Recent Posts

  • Did you know: SSPR/Password Reset Edition
  • How to Delete Recurring Planner Tasks with PowerShell
  • Why does my 365 Admin Audit Log sometime say it’s disabled, but other times enabled? Am I being compromised?
  • EntraFIDOFinder Update
  • New version of EntraFIDOFinder is out now

Categories

  • 365
  • Active Directory
  • AI
  • AzureAD
  • BlueSky
  • Cim
  • Dashboards
  • Documentation
  • Entra
  • Get-WMI
  • Learning
  • Module Monday
  • Nutanix
  • One Liner Wednesday
  • Passwords
  • PDF
  • Planner
  • PowerShell
  • Read-Only Friday
  • Reporting
  • Security
  • Windows
  • WSUS

© 2025 Clatent