PowerShell – How to use Select-String to search files for a pattern

In this article, I’ll show how to use the Select-String PowerShell command to search files in a directory with a regex pattern. I’ll first explain the basic syntax, and then I’ll show a few common search scenarios. Pattern, path, and alias Select-String has two main parameters: Note: The command name is not case-sensitive. You can … Read more

PowerShell – Get a file’s MD5 checksum

To get a file’s MD5 checksum, you can use Get-FileHash. This has been available since PowerShell v4. Use it like this: This file’s MD5 checksum is AE34D271ACC9C242BC9EED2E0EA72093. If Get-FileHash isn’t available Get-FileHash was put in PowerShell v4. If you’re on an earlier version, you’ll get following error when you try to use this: Get-FileHash is … Read more

PowerShell – Saving SQL query results to a CSV file

With PowerShell, you can execute a SQL query with Invoke-Sqlcmd. If you want to save the query results to a CSV file, you can use Export-Csv. Here’s an example: If Invoke-SqlCmd is missing, install the SqlServer module If it’s complaining about not having Invoke-SqlCmd available, you will need to install the SQL Server PowerShell module. … Read more

.NET – Signing code with a certificate

You’re given .PFX code signing certificate and told to sign your code. What does this mean, and how do you do it? What is code signing? Signing code means creating a digital signature on an executable file by using a code signing certificate. When your code is executed, your organization’s security software will check that … Read more