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

Clatent

Technology | Fitness | Food

  • About
  • Resources
  • Contact

One Liner Wednesday

One-Liner Wednesday January 4, 2023

January 4, 2023 by ClaytonT Leave a Comment

Today’s One-Liner Wednesday is one that is overlooked by many, but is very useful. It’s one of the basics that everyone should know or use. I’ll show you a few different options of it as a reminder for some and new knowledge for others.

Get-Help ModuleName -Online

This will give you a fully searchable web browser window for the help documentation of that module. This has helped me many times instead of trying to use the console window then all of the code you were working on is up above.

Get-Help ModuleName -ShowWindow

Does the same but opens it up in a different window that is searchable as well except it doesn’t support provider help.

Get-Help ModuleName -Examples

You would run this if you just wanted to see the examples for this module, and didn’t want to see anything else. You can do this for each of the help parameters as well if you just want one section of the help.

Get-Help -Name sql

This will search all the help articles and return any with the word SQL in it. You can use wildcards in this as well.

Get-Help about_*

This is another great one, this allows you to see all available conceptual articles, then you can pick which one you want. You can use wild cards on this as well to filter the results to more targeted information. Did you know there is an article for automatedlab_office ? Check it out and see!

Hope you found this helpful and be sure to check more out on get-help below as there is so much more it can do.

Microsoft Learn:
Get-Help

Tagged With: Help, One Liner Wednesday, PowerShell

One-Liner Wednesday December 28, 2022

December 28, 2022 by ClaytonT Leave a Comment

Today’s one-liner Wednesday will be great for system admins that need to see when and which updates were installed on a single server or multiple servers. It’s a quick and dirty way to do it, and I’m going to look around and see if there is a one with better formatting, but this gets the job done for now.

If you only need updates on one computer for the month of September 2022, this is all you need to do.

Export-InstalledPatchTOPDF -ComputerName localhost -month 9 -Year 2022

If you need multiple computers and want for a whole year, you would write this.

Export-InstalledPatchTOPDF -ComputerName localhost, server01, server02, server03 -Year 2022

And that’s it. As mentioned the output formatting could be a little better, but the functionality is great, and will reach out to him to see if he will be fixing it. If not, I’ll definitely be looking for another option.

PowerShell Gallery:
ExportInstalledPatchToPDFUpdated

Blog:
Prakash78

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

One-Liner Wednesday December 21, 2022

December 21, 2022 by ClaytonT Leave a Comment

It’s Wednesday, so you know what that means? A new one liner that I’m hoping is useful for you as it has been useful for me. I’ve talked about date and time before, but that was for selecting dates. What about if you wanted to figure out how many days till the end of the year, or how many seconds from current time to 3 months and 5 days from now is? Or when the last time a file was modified?

New-TimeSpan is your answer. Want to know how many days and seconds it is till the end of the year?

New-Timespan -end 12/31/2022

You can use the -Start parameter but isn’t needed unless you want to use a different start date.

What about if you only need the days because you will be putting it into a variable to use later on?

New-TimeSpan -end 12/31/2022 | select days

The final one I’ll leave you with is:

Get-ChildItem $PSHOME\onelinerwednesday.ps1 | New-TimeSpan

This will tell you the last time the file was updated. This can be great if you have scheduled tasks that run or if you need to find files that were edited in the last 3 hours or 3 years. This can also be used on any command that uses the -LastWriteTime property.

Let me know if you have used this before or what you intend to try it out on.

Tagged With: One Liner Wednesday, PowerShell

One-Liner Wednesday December 14, 2022

December 14, 2022 by ClaytonT Leave a Comment

Ever have to migrate a share? Or see who is still accessing a share you need to do work on and want to make sure everyone is off of it so the user doesn’t lose any data? Here is the perfect one liner.

Get-wmiobject -computername ServerName win32_serverconnection | select-object sharename,username,computername

All you have to do is put your Server name in and then this will show all shares that users are connected to with their computer name. You could run it right on your server you want to check the shares on as well. This has been super helpful when doing maintenance and when we’ve had to migrate storage to different servers/locations.

Microsoft Learn:
Get-wmiobject

Tagged With: One Liner Wednesday, PowerShell, Windows Server

One-Liner Wednesday December 7, 2022

December 7, 2022 by ClaytonT Leave a Comment

Today’s one liner is another basic one, but very powerful. Ever need to look for a file, or better yet multiple files then need to rename or delete them?

Get-Childitem -Path C:\windows -Recurse -Filter *test* -erroraction SilentlyContinue  | out-gridview -PassThru | Remove-Item -WhatIf

What this one liner will do is search all of the folders/files in the C:\Windows directory that have the word test in the file name or folder. It will even pull things like memtest.efi.mui and Microsoft.Windows.RemoteAttestation.Core.dll. The stars basically tell the search I can’t remember what else is after and/or before the letters I put, but I know there are letters there. Then with its results will put it into a nice window that you can select which file(s) you want to delete. Once you have highlighted the files/folders you want to delete, you can press ok, then they will be deleted(You will need to remove the “-WhatIf” from my code above because I like you, and just in case you just run this without double checking, files don’t get deleted)

Another thing to note is that I put the -Recurse parameter after the folder, this tells PowerShell to search sub directories too. If you remove it, it will only search that current directory.

And this can be used in the registry as well, just make sure that -WhatIf is used until you are 100% the code is working correctly.

Microsoft Learn:
Get-ChildItem

Tagged With: Get-ChildItem, One Liner Wednesday, PowerShell

One-Liner Wednesday November 30, 2022

November 30, 2022 by ClaytonT Leave a Comment

It’s already Wednesday, can you believe it? Nothing crazy initially from today’s one liner, but once you learn the concepts, your imagination is the limit.

# Local Computer

(gcim Win32_OperatingSystem).LastBootUpTime

# Remote Computer

$s = new-cimsession -computername comp1,comp2 -credential credential

(gcim Win32_OperatingSystem -CimSession $s).LastBootTime

**GCIM is an alias for Get-CimInstance

So what does all of this mean? The first script will give you the last time your local computer booted up, and the second one does it for a remote computer. This is a great one liner(technically 2 for the remote as you need to create the CimSession) for you or your support team to make sure the user has really restarted their computer. Also a great way to check if a script you have that is supposed to reboot the device actually reboots it, and to not go any farther until the reboot has actually happened. I’d recommend having this one liner in your toolbox as well as creating a function out of it so that you can put parameter’s in place to make it even easier for your support team to use.

You also can see that I created a CimSession for the remote computer(s). This makes connecting to remote computers much easier and allow you to scale when needing information from CIM commands.

There is just so much information that you can get from the CimInstances and CimClass, that I can’t put here, but if you are looking for any thing related to hardware to a device check out these out. You can even see how much battery charge is left in a computer.

Get-CimInstance:
Microsoft Learn

Get-CimSession:
Microsoft Learn

CIM Classes:
Microsoft Learn

Tagged With: Cim, One Liner Wednesday, PowerShell, Remote

  • « Go to Previous Page
  • Page 1
  • Page 2
  • Page 3
  • Page 4
  • 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

  • Learning ValidateSet in PowerShell: Valid Values Only
  • Teams Chat and PowerShell – How to add value!
  • EntraFIDOFinder: New Web UI and Over 70 New Authenticators
  • January 19, 2026 Updates to EntraFIDOFinder
  • v0.0.20 EntraFIDOFinder is out

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