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

Clatent

Technology | Fitness | Food

  • About
  • Resources
  • Contact

The Blog

One-Liner Wednesday February 22, 2023

February 22, 2023 by ClaytonT Leave a Comment

Ever wanted a quick and easy way to see what operating systems all your computers are running to the detail of the version number? Then wanting to know the last time they logged on?

PowerShell provides a powerful and efficient way to perform this task. In this blog post, we will show you how to use a PowerShell one-liner to search for computers in a specific OU and view their name, operating system, OS version, and last time they logged in.

Searching for computers in a specific OU

You can start by searching for computers in a specific OU. The “Get-ADComputer” cmdlet can be used to retrieve information about computer objects in Active Directory. Here is an example command that retrieves all computers in the “Computers” OU:

Get-ADComputer -SearchBase "OU=Computers,DC=example,DC=com" -Filter * -Properties Name, OperatingSystem, OperatingSystemVersion, LastLogonDate

This command uses the “-SearchBase” parameter to specify the distinguished name of the search base where the search should be conducted. In this case, we are searching in the “Computers” OU of the “example.com” domain. You should replace this with the distinguished name of the OU you want to search in.

The “-Filter” parameter is used to retrieve all computer objects in the specified OU, and the “-Properties” parameter is used to specify the properties you want to retrieve. In this case, we are retrieving the “Name”, “OperatingSystem”, “OperatingSystemVersion”, and “LastLogonDate” properties.

Formatting the output

The output of the previous command is not very user-friendly, so we need to format it to make it easier to read. We can use the “Select-Object” cmdlet to select the properties we want to display and format the output using the “Format-Table” cmdlet. Here is the final PowerShell one-liner:

Get-ADComputer -SearchBase "OU=Computers,DC=example,DC=com" -Filter * -Properties Name, OperatingSystem, OperatingSystemVersion, LastLogonDate | Select-Object Name, OperatingSystem, OperatingSystemVersion, @{Name="LastLogonDate";Expression={[DateTime]::FromFileTime($_.LastLogonDate)}} | Format-Table -AutoSize

This command retrieves all computer objects in the specified OU and selects the “Name”, “OperatingSystem”, “OperatingSystemVersion”, and “LastLogonDate” properties. The “LastLogonDate” property is converted to a readable date format using the “FromFileTime” method of the “DateTime” class. Finally, the output is formatted using the “Format-Table” cmdlet to display the information in a table format. You could even change “Format-Table” and use “Out-GridView” to give you an excel like experience where you can filter and sort columns… and to make it even more advance if you are trying to remove or disable computers, you could use the Out-GridView with a “-PassThru” parameter then pipe it to a delete or disable. ***Make sure to use -WhatIf so you don’t by accident delete all of the computers that you searched for!

Conclusion

In this blog post, we have shown you how to use a PowerShell one-liner to search for computers in a specific OU in your Active Directory and view their name, operating system, OS version, and last time they logged in. This information can be very useful for managing your domain and keeping track of your computers. This can be used for reporting and for autoamating tasks that only pertain to certain versions of Windows OS. By using PowerShell, you can quickly and easily retrieve this information and format it in a way that is easy to read and understand while using it for automations.

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

Module Monday February 20, 2023

February 20, 2023 by ClaytonT 2 Comments

Hope you had a great weekend! And since the weekend is over, it’s now time for Module Monday. We have a great one today that I feel you will see immediate ROI from using it.

uGit by James Brundage is a PowerShell module that provides users with a simplified interface to interact with Git repositories. It includes a set of functions that can be used to perform various Git-related tasks, such as cloning repositories, committing changes, pushing and pulling changes, and creating branches, among others. Here are some of the key features of uGit:

Simple and Easy to Use

uGit provides users with a simplified interface to interact with Git repositories. The module’s functions are easy to use and don’t require users to have extensive knowledge of Git commands. With uGit, users can automate their Git workflows with just a few lines of PowerShell code.

Git Repository Management

uGit includes functions for managing Git repositories, such as cloning, creating, and deleting repositories. The module also provides users with the ability to switch between repositories and set a default repository for their Git workflow.

Committing and Pushing Changes

With uGit, users can easily commit and push changes to their Git repositories. The module includes functions for adding and removing files from the staging area, committing changes, and pushing changes to the remote repository.

Branch Management

uGit includes functions for creating and deleting Git branches, as well as switching between branches. The module also provides users with the ability to merge branches and resolve merge conflicts.

Git Configurations

uGit provides users with the ability to set and manage their Git configurations, such as user name and email, Git editor, and Git credentials.

In conclusion, uGit users can automate their Git workflows and perform complex Git-related tasks with ease. If you’re a PowerShell user looking to integrate Git functionalities into your workflows, uGit is definitely worth checking out.

Github:
uGit

PowerShell Gallery:
uGit 0.3.6

Tagged With: Module Monday, PowerShell

Read-Only Friday February 17, 2023

February 17, 2023 by ClaytonT Leave a Comment

It’s been a little bit for a Read-Only Friday, and need your input. Do you like the 3 days of smaller posts, or would you rather have one more in depth post a week, possibly every 2 weeks? They would be targeted to real life examples using PowerShell or scenarios in IT and how to best handle them. Would love your feedback and feel free to message me if you rather not put it in here!

Remember, no major unplanned changes today unless mission critical! And might be a good day to review your documentation to make sure it is up date or anyway you can improve it!

Tagged With: PowerShell, Read-Only Friday

One-Liner Wednesday February 15, 2023

February 15, 2023 by ClaytonT Leave a Comment

I’m just going to cut to the chase on this one..

 copilot "How to filter ID column not being empty and if it isn't empty it starts with a number and the other column named sideindicator having a r in it using powershell and importexcel and both criteria must be true?"
╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
║Q: How to filter ID column not being empty and if it isn't empty it starts with a number and the other column named sideindicator having a r in it using powershell and importexcel and both criteria must be true?  ║
║═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════║
║1: $data = Import-Excel -Path "C:\Path\To\File.xlsx"                                                                                                                                                                 ║
║2: $data | Where-Object {$_.ID -and $_.ID -match '^\d' -and $_.SideIndicator -eq 'r'}                                                                                                                                ║
╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝

How about that? Nice little RegEx in there too! Yes this does work, as I used it this morning for a real life solution.

Download Doug Finke’s PowerShellAI module, get your OpenAI API key, and start having some fun! And if for some reason you still haven’t downloaded his ImportExcel module get that too! And want to hear a little more about Doug, check him out on the PowerShell Podcast and find out how ImportExcel is created.

That’s enough for today, I don’t want to take away your time from playing with this!

PowerShell Gallery:
PowerShellAI

GitHub:
PowerShellAI

Tagged With: AI, One Liner Wednesday, PowerShell

Module Monday February 13, 2023

February 13, 2023 by ClaytonT Leave a Comment

It’s Monday after the Super Bowl so we are going to keep this lite.  Today’s module isn’t business related at all, unless your in the Lego business. It’s a great module that helps you view and maintain your Lego collection. 

With that said, welcome the Brickset Module. I’ve already been playing with it and really like it. I was initially going to make my own, but I rather use his as a base and expand off of it.

If you already have your collection in a csv or xlsx it makes it super easy to add them in, instead of going to the website to add them each. If you already have a brickset account and an excel sheet? I’m working on a script to compare and sync between the two.

Any option on the Brickset website can be done in the module, see how many pieces or mini figs you have, see only certain themed sets, and even pulling instructions for sets you have!

Hope this makes your Lego experience even more fun and you get to learn/practice PowerShell skills while playing with it!

I’ll be working on some dashboards too in the near future. Any certain things you want to see?

GitHub:

https://github.com/jonathanmedd/BricksetModule

Tagged With: Lego, Module Monday, PowerShell

One-Liner Wednesday February 8, 2023

February 8, 2023 by ClaytonT Leave a Comment

This week’s One-Liner is brought to you by no other than Steve Lee. I can’t take credit for it, but want to make sure others see it. The only caveat is that it needs to be run in an elevated session.

Invoke-Expression "& { $(Invoke-RestMethod 'https://aka.ms/install-powershell.ps1') } –useMSI -Quiet"

It does what you think it does… installs PowerShell 7, using the MSI and silently. I’ve used it before many times and works great. There are also many other switches you can which I’ve linked to the GitHub below.

A few are:
Daily
DoNotOverwrite
AddtoPath
Preview

Try it out, and let me know what you think!

GitHub:
One-Liner

Tagged With: Automation, One Liner Wednesday, PowerShell

  • « Go to Previous Page
  • Page 1
  • Interim pages omitted …
  • Page 10
  • Page 11
  • Page 12
  • Page 13
  • Page 14
  • Interim pages omitted …
  • Page 20
  • 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

  • New EntraFIDOFinder Module Version Release!
  • Did you know there is a Giphy rating in Teams? Custom Maester Tests save the day
  • Learning ValidateSet in PowerShell: Valid Values Only
  • Teams Chat and PowerShell – How to add value!
  • EntraFIDOFinder: New Web UI and Over 70 New Authenticators

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
  • Uncategorized
  • Windows
  • WSUS

© 2026 Clatent