Starting EXE Files with Start-Process (Improved)

PowerShell has many different ways to start a process. We’ve got Start-Process, Invoke-Expression, we can call the executable directly or use the ampersand (&) to invoke expressions. The most common way is to use Start-Process because it’s probably the most intuitive. PowerShell is known for it’s intuitive approach to command naming and Start-Process is an excellent choice. However, that command […]

Read more

Create Azure SQL Databases with PowerShell and Azure Resource Manager Templates

Microsoft’s premade templates allow for the deployment of SQL databases without having to use complex PowerShell commands. There are lots of ways to create MSSQL databases via PowerShell. We could invoke a T-SQL query using the CREATE DATABASE term, we could write some code to use the [Create() method with SMO] or, if we’re putting this SQL server in Azure, we could […]

Read more

Understanding the OutputType Keyword in PowerShell

 PowerShell’s tab-completion ability is great, but by using the OutputType keyword properly in your PowerShell functions, we can make it even better. Whenever you’re working with PowerShell, have you ever noticed that at certain times, you could start hitting the Tab key, and it somehow knows what’s available to you? This tab completion can work with function parameters, variables, and […]

Read more

Try/Catch/Finally Blocks in PowerShell for Better Error Handling

A concept in many programming languages is the exception, and one way to deal with these exceptions is by using a try/catch block in PowerShell. The try/catch block with an optional finally block creates a “box” around code that forces it to send all thrown exceptions into the catch block for further processing. PowerShell has two types of errors: terminating errors and […]

Read more

Log Off Multiple Users on a Schedule With PowerShell

 The PowerShell script discussed in this post allows you to log off multiple users on multiple computers. One of the issues when performing tasks like deploying software or making user-based configuration changes is dealing with interactive logons. We try to avoid it, but sometimes we have to force users to log off the machine to apply the changes we need. […]

Read more

Debug PowerShell With the Debugger. Here’s How.

 The term “debug” can mean a lot of things, but in the PowerShell sense, I’m referring to “debugging” as using the PowerShell debugger. Some consider debugging a black art. It’s an activity shrouded in mystery until you actually sit down to learn! Especially with IT pros, we think of debugging code as something only developers do. But as PowerShell becomes […]

Read more
1 2 3 50