• 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 25, 2023

January 25, 2023 by ClaytonT Leave a Comment

Today’s one-liner is one that you or may not have to use a lot depending how your environment is setup and how you setup computers. Either way, its great to have it so you don’t have to go digging for it in the GUI. Ever had a time when you are trying to connect to a computer, and can’t? You make sure the computer is connected to the right wifi or that it is wired in, has the right IP address, and has internet… but nothing seems to work. Then you turn off your firewall and you can ping it… you know you can’t leave the firewall off all the time. What to do?

Set-NetFirewallRule -DisplayName "File and Printer Sharing (Echo Request - ICMPv4-In)" -Enabled True

There is your answer. That simple one line of code enables pinging without turning off your whole firewall. You can do this in group policy or add it to your golden image for imaging computers.

Hope this helps and saves time you prepping computers!

Tagged With: Automation, Firewall, One Liner Wednesday, PowerShell

One-Liner Wednesday January 18, 2023

January 18, 2023 by ClaytonT 2 Comments

Do you use 365? Ever needed a quick list of all your users and their mailbox size? What about having it nicely formatted? Or do you only want to see a certain size mailbox? This quick one-liner is a good starting point.

Get-EXOMailbox -ResultSize Unlimited | Get-EXOMailboxStatistics | Select DisplayName, ItemCount, TotalItemSize | Sort-Object TotalItemSize -Descending | Export-Excel -Path C:\scripts\MailboxSizes.xlsx -AutoSize

What this does is uses the current way to get a 365 mailbox(Get-mailbox is deprecated), grabs all the mailboxes, selects only the Display name, amount of emails, and total size of their mailbox. It will then put the largest mailbox at the top and smallest at the bottom. After all of that, it exports it to an excel file that you can manipulate how you like. If you haven’t already used Doug Finke’s ImportExcel module, I’d recommend it to get creative with your formatting without ever opening Excel to format. You could add it so all mailboxes over a certain size are a certain color.

Hope this helps let me know if you expand on this even if its not a one liner, I’d love to see!

Tagged With: 365, Exchange, One Liner Wednesday, PowerShell, Reporting

One-Liner Wednesday January 11, 2023

January 11, 2023 by ClaytonT 2 Comments

It’s Wednesday already, is that good or bad for you? Hoping it’s a good thing, and hoping todays one-liner makes it even better.

$Path = $env:TEMP; $Installer = 'chrome_installer.exe'; Invoke-WebRequest -Uri 'http://dl.google.com/chrome/install/375.126/chrome_installer.exe' -OutFile $Path\$Installer; Start-Process -FilePath $Path\$Installer -Args '/silent /install' -Verb RunAs -Wait; Remove-Item -Path $Path\$Installer

What this one-liner will do is go out and fetch chrome and silently install or update it. Then it will delete the installer after it has been installed. You could add lines for logging in case you had other software that you wanted to install after, but I feel this is a great foundation if you’ve never done it before. If you start adding logging and other features(ie. confirming it has installed), I’d definitely take it out of the one-liner format for ease of reading/troubleshooting unless for some reason you need to keep it as a one-liner.

You can do this with many applications, you just have to make sure the URI and switches(Args) are correct.

Tagged With: App Deployment, Applications, One Liner Wednesday, PowerShell

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

  • Go to page 1
  • Go to page 2
  • Go to 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

  • One-Liner Wednesday January 25, 2023
  • Module Monday January 23, 2023
  • One-Liner Wednesday January 18, 2023
  • Module Monday January 16, 2023
  • Read-Only Friday January 13, 2023

Categories

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

© 2023 Clatent