Code base

Code base for PowerShell scripting, PHP, ASP/VBScript, ASP.NET/C#, ASP.NET Core, Perl, code snippets and examples. Snippets are small pieces of reusable code.

PowerShell

Calculate SHA-256 checksums in PowerShell

If you need to verify files are untampered with, you have to create a file checksum -or file hash- that you can use to verify. PowerShell offers this functionality with Get-FileHash cmdlet. Or use certutil.exe.

PowerShell

Install Windows Updates using PowerShell

In this post I show you how you can use PowerShell to install Windows Updates. Quickly and silently. This makes the use of PSWindowsUpdate module perfect for your day to day automation. The module even supports scheduling (on remote computers too!), it has the ability to search WSUS and Windows Update for updates, scheduling and performing the download and installation of updates.

PowerShell

Send email with PowerShell

In this post I provide you with a small PowerShell function you can use to send email over a TLS secured SMTP connection with SMTP authentication. As a framework you can use in your own scripting and extend it. You can even create a PowerShell module of it.

PowerShell PowerShell 5.0

Emulate ternary operator in PowerShell

Emulate ternary or conditional operator in PowerShell 5. It takes three operands: a condition followed by a question mark (?), then an expression to execute if the condition is truthy followed by a colon (:), and finally the expression to execute if the condition is falsy. This operator is frequently used as an alternative to an if…else statement.

PowerShell

Use -SearchBase with Get-ADComputer for faster results

Using -SeachBase with PowerShell’s Get-ADComputer cmdlet gives faster results when querying Active Directory Domain Services (AD DS) with PowerShell. You can use this for your own advantage, here is a little example to speed up AD DS queries.

PowerShell PowerShell 5.0

Install Windows Server Servicing Stack Updates (SSU) using PowerShell

Install Servicing Stack Updates (SSU) for Windows Server 2012R2, 2016 and Windows Server 2019 using PowerShell, without downtime. Because they must be installed prior to normal Windows Server security updates you can install an SSU anytime you want to during the day. Here’s a small PowerShell example to do so.

Code base

MySQL Connector/ODBC C# test script

Whenever you need to test your ASP.NET connection to your MySQL database, using ODBC, you can use the following C# test script. Currently it uses MySQL ODBC 8.0 Unicode Driver, but you can easily change the version used. As a bonus it prints some connection information and it requires an SSL connection to your MySQL database (SslMode=REQUIRED).

PowerShell

Working with file attributes in PowerShell

Here is how to use Get-Item and Get-ItemProperty in PowerShell to perform and streamline day to day tasks like installing or updating software based on file versions. Working with PowerShell’s Get-ItemProperty to get file attributes may boost your work productivity. It’s often easier to getting things done if you have a more generic way of doing something. I also address changing timestamps on files in short.