Press "Enter" to skip to content

Category: Powershell

Log Analysis with Powershell

Chad Baldwin doesn’t need no fancy GUIs:

Let’s talk about how to make something that’s already super exciting, even more fun, by using PowerShell. Why bother with fancy GUI’s and polished tools when you can do it the fun way?

Yes, there’s lots of good options now when it comes to logging, like structured logs, AWS CloudWatch, Azure Monitor, ELK, etc. Tools that give you a lot of power when it comes to filtering, alerts, and monitoring. However, I still often find myself digging through good ol’ *.log files on a server.

Read on for some good information about how to analyze a log file using nothing more than Powershell.

Comments closed

Automating Remote Execution via Powershell and SQL Server

Eitan Blumin dives into Powershell:

As part of my journey to get better at Powershell, I gave myself a task: Create a project utilizing Powershell at its core, to solve a complicated problem as elegantly as possible.

A complicated problem indeed presented itself: How to remotely control multiple computers without having to log into them? Make them perform any task that could possibly be needed? Control them from one central location? And make the solution as easily scalable as possible?

Read on to see what Eitan has learned and applied.

Comments closed

Setting Powershell’s TLS Version

Frank Gill updates TLS:

I was recently working on a client server and need to install the Az PowerShell module. I opened and administrator window and typed

Install-Module Az

and received this error:

WARNING: Unable to find module repositories.

Turns out that was not the real answer. Click through to see what Frank ended up needing to do.

Comments closed

PSProjectStatus

Jeffery Hicks wants to check Git status:

I write a lot of PowerShell modules. And probably like you, I am working on more than one project at a time. I was finding it difficult to keep track of what I was working on and what I might be neglecting. So I turned to PowerShell and created a tool that I use to keep on top of my projects. The PowerShell module is called PSProjectStatus and you can install it from the PowerShell Gallery. You can find the project on GitHub, but I thought I’d provide an introduction here.

Read on to see how it works.

Comments closed

Working with SIDs in Powershell

Jeffery Hicks translates security identifiers:

As usually happens during my day, I get sidetracked to another issue, and before you know it, I have a new PowerShell tool. In this instance, I was looking at event logs using Get-WinEvent. One of the event record properties is a UserID.

That’s very nice, but who is this? In this particular instance, the UserID property is SecurityIdentifier object.

Read on to see how to translate a SecurityIdentifier into something human-understandable.

Comments closed

Building a SQL Server Inventory via Powershell

Lee Markum wants to figure out where all the servers are:

You’re a data professional and you’ve been given the keys to a new SQL Server environment. You know you need to build a SQL Server inventory so you know what is in your environment, but how do you get that information?

One of the things I have talked about in other posts is how to create a SQL Server inventory. I’ve discussed using the MAP Toolkit and building your own inventory database using T-SQL. Today, we’ll see another way to generate a list of SQL Servers in your environment.

Click through for that method. In the past, I’ve used nmap (with permission, of course) to figure out all the SQL Server instances in my environment. Fun times.

Comments closed

Running a SQL Assessment from Powershell

David Alcock performs a bit of assessment:

My last post covered the SQL Assessment extension in Azure Data Studio and in this article I’m going to look at running the SQL Assessment API using PowerShell instead. Whilst in ADS we can export assessment results to HTML or into SQL via a script the PowerShell option is a bit more flexible, we can export straight to a SQL table and run the assessment across multiple instances.

I’ll follow the PowerShell instructions from the SQL Assessment API web page; this is the code that will run the assessment on my localhost instance and it will also write the results to a table (Assessment.Results) in the SQLAssessmentDemo database, the -Force parameter will create the objects if they don’t already exist:

Read on for that code as well as a few tweaks you can make to make your life easier.

Comments closed

Color Palettes in Powershell and WPF

Jeffrey Hicks has been working with color lately:

Let’s continue looking at how to use PowerShell and a Windows Presentation Foundation (WPF) form to display [System.Drawing.Color] values. This article builds on an earlier post so if you missed it, take a few minutes to get caught up. As I did earlier, before running any WPF code in PowerShell, you should load the required type assemblies.

This has been a fun series to watch.

Comments closed

Overloading Methods in Powershell

Robert Cain continues a series on classes in Powershell:

This is the next installment in our series of advanced techniques for PowerShell classes. In the previous installment we saw how to implement static properties and methods. In this one, we’ll see how to overload your methods.

We’ll take a deeper look at overloading in a moment, but first let me mention that for all of the examples we’ll display the code, then under it the result of our code when applicable. In this article I’ll be using PowerShell Core, 7.2.1, and VSCode. The examples should work in PowerShell 5.1 in the PowerShell IDE, although they’ve not been tested there.

Read on to see how overloading works in .NET.

Comments closed