Skip to content
MidnightDBA

MidnightDBA

We make videos while you sleep

  • About us
  • Links
  • FAQs
  • Contact

Category: Powershell

Microsoft SQL Server – Powershell Splatting

Help keep your command code organized by splatting parameters. Continue reading “Microsoft SQL Server – Powershell Splatting”

Author Sean McCownPosted on March 14, 2022May 11, 2022Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Powershell Classes: Part 5 – Inheritance con’t

Here we finish up the discussion on inheritance and we Continue reading “Powershell Classes: Part 5 – Inheritance con’t”

Author Sean McCownPosted on February 3, 2022February 3, 2022Categories Administration, Development, Powershell

Powershell Classes: Part 3

This is part 3 of our series on how to
create classes in powershell.
We start by going over homework and then get into hidden classes and creating a fire hazard in our code.

Watch Part 1
Watch Part 2
Watch Part 4
Watch Part 5

 

Author Sean McCownPosted on January 5, 2022February 3, 2022Categories Administration, Development, PowershellTags Administration, Enterprise Administration, Powershell

Classes in Powershell: Part 2

Classes in Powershell: Part 2

Here I’m continuing my live class in writing classes in powershell. We go over adding some useful properties and developing a help system.

Watch Part 1
Watch Part 3

Author Sean McCownPosted on January 5, 2022January 6, 2022Categories Administration, PowershellTags Administration, Powershell

Classes in Powershell: Part 1

Classes in Powershell: Part 1

Ever want to create your own classes in powershell? Continue reading “Classes in Powershell: Part 1”

Author Sean McCownPosted on December 25, 2021January 6, 2022Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Powershell Error Handling Basics 2

Powershell Error Handling Basics 2

Continuing with our discussion on PS error handling.

Watch the first vid here:

Powershell Error Handling Basics – MidnightDBA

Author Sean McCownPosted on September 17, 2021January 5, 2022Categories Administration, PowershellTags Administration, Development, Enterprise Administration, Powershell

Powershell Error Handling Basics

Powershell Error Handling Basics

This is a live session where I teach someone the
basics of PS error handling.

Here’s the 1st vid in the series.

Powershell Error Handling Basics 2

Author Sean McCownPosted on September 10, 2021January 5, 2022Categories Administration, PowershellTags Administration, Development, Enterprise Administration, Powershell

Beginning SQL Server SMO

Beginning SQL Server SMO

Recently I was invited to talk about beginning SMO on Continue reading “Beginning SQL Server SMO”

Author Sean McCownPosted on February 25, 2019February 25, 2019Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell, SMO1 Comment on Beginning SQL Server SMO

Loading SQL Data From Powershell

Loading SQL Data From Powershell

Learn how to load data into and out of SQL Continue reading “Loading SQL Data From Powershell”

Author Sean McCownPosted on October 31, 2018October 31, 2018Categories Administration, PowershellTags Administration, Development, Enterprise Administration, Powershell

Beginning Powershell for DBAs: Part 1

Beginning Powershell for DBAs: Part 1

The time has come where DBAs can no longer afford to ignore Powershell. Not only has it become an integral part of SQL Server, but Continue reading “Beginning Powershell for DBAs: Part 1”

Author Sean McCownPosted on April 5, 2018July 13, 2018Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Script PK/FKs in Powershell

Script PK/FKs in Powershell

Here I show you how to script out objects that belong to tables like primary keys, forgeign keys, constraints, and indexes with powershell. It’s Continue reading “Script PK/FKs in Powershell”

Author Sean McCownPosted on December 7, 2017December 20, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Object Properties in Powershell

Object Properties in Powershell

This is a great video that shows you how to look at the properties collection in objects and explains what the different properties mean. Continue reading “Object Properties in Powershell”

Author Sean McCownPosted on December 7, 2017December 20, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Get SQL Server Root Dir in Powershell

Get SQL Server Root Dir in Powershell

Here we’re finding the root install directory for SQL Server.

Author Sean McCownPosted on December 7, 2017December 21, 2017Categories Administration, PowershellTags Administration, Powershell

Truncate Tables in Powershell

Truncate Tables in Powershell

Here I show you how to truncate a mass of tables in the same schema. Of course, you don’t have to limit it to Continue reading “Truncate Tables in Powershell”

Author Sean McCownPosted on December 7, 2017December 21, 2017Categories Administration, PowershellTags Administration, Powershell

Drop Tables in Powershell

Drop Tables in Powershell

Today I’m dropping tables based off of a regex expression and by rowcount. Good stuff here. The power of the shell shines through Continue reading “Drop Tables in Powershell”

Author Sean McCownPosted on December 7, 2017December 21, 2017Categories Administration, PowershellTags Administration, Powershell, Regex

Server Configuration Settings in Powershell

Server Configuration Settings in Powershell

I love making vids on the trickier stuff and this one is it. Here we’re talking about duplicating sp_configure in Powershell. It’s pretty Continue reading “Server Configuration Settings in Powershell”

Author Sean McCownPosted on December 7, 2017December 21, 2017Categories Administration, PowershellTags Administration, Config, Powershell

Change Startup Params in Powershell

Change Startup Params in Powershell

I heard someone today say that you can’t change startup parameters in Powershell. So I made this vid to set the record straight.

Author Sean McCownPosted on December 7, 2017December 21, 2017Categories Administration, PowershellTags Administration, Config, Powershell

Cycle Error Log on all Servers using Powershell

Cycle Error Log on all Servers using Powershell

Here I show you how to use the Carrier Method for using powershell to cycle all your error logs. This is an excellent way Continue reading “Cycle Error Log on all Servers using Powershell”

Author Sean McCownPosted on December 7, 2017December 21, 2017Categories Administration, PowershellTags Administration, Config, File issues, Powershell

Read SQL Server Error Logs in Powershell

Read SQL Server Error Logs in Powershell

Would you like to work with the SQL Server error logs in Powershell? Well here I’m gonna show you how. Not only do Continue reading “Read SQL Server Error Logs in Powershell”

Author Sean McCownPosted on December 7, 2017December 21, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Change SQL Server Permissions in Powershell: Part 2

Change SQL Server Permissions in Powershell: Part 2

Continuing from the 1st video, here I show you how to capture useful errors from the method call. I explain how to Trap the Continue reading “Change SQL Server Permissions in Powershell: Part 2”

Author Sean McCownPosted on December 7, 2017December 21, 2017Categories Administration, Powershell, SecurityTags Administration, Powershell, Security

Change Schema in Powershell

Change Schema in Powershell

Changing object schemas is easy enough in T-SQL when it’s a single object, but it get considerably more complicated when you’ve got several objects to Continue reading “Change Schema in Powershell”

Author Sean McCownPosted on December 7, 2017December 21, 2017Categories Administration, PowershellTags Administration, Powershell

Get IP and DNS in Powershell

Get IP and DNS in Powershell

Getting IP address and DNS info from your servers in a useful format isn’t as straightforward as you would think. Here I’m going to Continue reading “Get IP and DNS in Powershell”

Author Sean McCownPosted on December 7, 2017December 21, 2017Categories Administration, PowershellTags Administration, Powershell

Calling Detach Methods in Powershell

Calling Detach Methods in Powershell

Detaching DBs in Powershell is pretty easy, which is why you should learn how to do it. It takes less typing than the t-sql Continue reading “Calling Detach Methods in Powershell”

Author Sean McCownPosted on December 7, 2017December 21, 2017Categories Administration, PowershellTags Administration, Powershell

Attach DBs in Powershell

Attach DBs in Powershell

This continues the series on detach/attach for DBs. Along the way I show you how to deal with a powershell provider bug, work with Continue reading “Attach DBs in Powershell”

Author Sean McCownPosted on December 7, 2017December 21, 2017Categories Administration, PowershellTags Administration, Powershell

Replace sp_MSForEachDB with Powershell

Replace sp_MSForEachDB with Powershell

A user request came in to write something in powershell that would replace sp_MSForEachDB. I took it a step further and showed you how Continue reading “Replace sp_MSForEachDB with Powershell”

Author Sean McCownPosted on November 14, 2017December 21, 2017Categories Administration, PowershellTags Administration, Powershell

Sum DB Sizes with Powershell

Sum DB Sizes with Powershell

Quite often it can be useful to not only get a list of DB sizes, but also sum it up in the last line. Continue reading “Sum DB Sizes with Powershell”

Author Sean McCownPosted on November 14, 2017December 20, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Audit Service Accounts with Powershell

Audit Service Accounts with Powershell

How would you like to be able to audit your service accounts with powershell so you can tell how many boxes are running on the Continue reading “Audit Service Accounts with Powershell”

Author Sean McCownPosted on October 10, 2017October 25, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Monitor Backups with Powershell

Monitor Backups with Powershell

I know you guys are just begging for an easy way to monitor your backups and alert when one hasn’t been backed up recently. Continue reading “Monitor Backups with Powershell”

Author Sean McCownPosted on October 10, 2017October 25, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Start Agent Jobs in Powershell

Start Agent Jobs in Powershell

Starting SQL Agent jobs in powershell is easy, but there’s a trick to it that’s not obvious. Here I’ll show you how to start Continue reading “Start Agent Jobs in Powershell”

Author Sean McCownPosted on October 10, 2017October 25, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Start Agent Jobs in Powershell: Part 2

Start Agent Jobs in Powershell: Part 2

Starting SQL Agent jobs in powershell part 2.

Author Sean McCownPosted on October 10, 2017October 25, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Manage DB Files in Powershell

Manage DB Files in Powershell

I’m excited to be able to film this one because it has the potential to save you so much time and effort. I’m showing Continue reading “Manage DB Files in Powershell”

Author Sean McCownPosted on October 10, 2017October 25, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Get Table Stats with Powershell

Get Table Stats with Powershell

Let’s get stats for every table in the DB and put them in a file so we can send them to a customer or view Continue reading “Get Table Stats with Powershell”

Author Sean McCownPosted on October 10, 2017October 25, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Build .Net Objects in Powershell

Build .Net Objects in Powershell

I just love the topic of this video. Here we show you how to create .NET code with powershell. While we create an Continue reading “Build .Net Objects in Powershell”

Author Sean McCownPosted on October 6, 2017October 25, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Change DB Compatibility Level in Powershell

Change DB Compatibility Level in Powershell

Here I show you 2 easy ways to change the DB compatibility level in powershell. Otherwise you have to use a T-SQL cursor and Continue reading “Change DB Compatibility Level in Powershell”

Author Sean McCownPosted on October 6, 2017October 25, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Get a Specific Method in Powershell

Get a Specific Method in Powershell

Sometimes the list of properties and methods is too big to sift through when you do a get-member on an object. Here I’ll show Continue reading “Get a Specific Method in Powershell”

Author Sean McCownPosted on October 6, 2017October 25, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Add User to Windows Group with Powershell

Add User to Windows Group with Powershell

I love this video because it’s so unusual to find something like it in the DBA community. We’re quite often called on to do Continue reading “Add User to Windows Group with Powershell”

Author Sean McCownPosted on October 6, 2017October 25, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Replace Text in File

Replace Text in File

Here I show you how to replace a given string in a file and either write it back to the same file, or write the Continue reading “Replace Text in File”

Author Sean McCownPosted on October 5, 2017December 21, 2017Categories Administration, PowershellTags Administration, File issues, Powershell

Index Scripting Problems

Index Scripting Problems

This is just a fun vid. Again, we’re sitting here late at night feeling a little punchy so we’re a little goofier than usual.

Author Sean McCownPosted on October 5, 2017December 21, 2017Categories Administration, PowershellTags Administration, Powershell

Beginning Powershell for DBAs 4

Beginning Powershell for DBAs 4

Here I continue with the 4th class in the series at the NTSSUG user group.

Author Sean McCownPosted on October 5, 2017October 25, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Find DB Files with Powershell

Find DB Files with Powershell

Here I need to find the .MDF for a database so I can attach it, but I have no idea where the .MDF is.

Author Sean McCownPosted on October 5, 2017October 25, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Pass Params to Scripts (Powershell)

Pass Params to Scripts (Powershell)

Wanna know how to pass parameters to scripts, and when to use each method?

Author Sean McCownPosted on October 5, 2017October 25, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Building a Powershell BCP Routine

Building a Powershell BCP Routine

Here I show you how to build a script that will BCP an entire group of tables and even log the progress. You can Continue reading “Building a Powershell BCP Routine”

Author Sean McCownPosted on October 2, 2017October 25, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Beginning Powershell for DBAs 1

Beginning Powershell for DBAs 1

This is an excellent video that explains what schemas are and why you should care.

Author Sean McCownPosted on October 2, 2017October 25, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

PowerShell Basics

PowerShell Basics

Here I start the first in an exciting new series of vids on PowerShell both in Windows and SQL. I go over how to Continue reading “PowerShell Basics”

Author Sean McCownPosted on October 1, 2017October 25, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Scripting DB Objects in PowerShell

Scripting DB Objects in PowerShell

Continuing with PowerShell I thought I’d show you something really cool you can do that would make a difference in your shop right away. So Continue reading “Scripting DB Objects in PowerShell”

Author Sean McCownPosted on October 1, 2017October 25, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Scripting DB Objects in Powershell (Advanced Topics)

Scripting DB Objects in Powershell (Advanced Topics)

Here I get past the basics of using the Script() method and take you to how to recreate some of the scripts you can create Continue reading “Scripting DB Objects in Powershell (Advanced Topics)”

Author Sean McCownPosted on October 1, 2017October 25, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Working with PSDrive in PowerShell

Working with PSDrive in PowerShell

Here I go over what PSDrive is and how to work with it. I also go into aliases again as well as how to Continue reading “Working with PSDrive in PowerShell”

Author Sean McCownPosted on October 1, 2017October 25, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Powershell with –NoExit

Powershell with –NoExit

Here I show you how to get around the problem of your Powershell window closing down when you call it from either the run window Continue reading “Powershell with –NoExit”

Author Sean McCownPosted on October 1, 2017October 25, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Grant DB Permissions

Grant DB Permissions

This is a beautiful bit of script that allows you to set DB permissions for a user. This is particularly useful for adding a Continue reading “Grant DB Permissions”

Author Sean McCownPosted on October 1, 2017October 25, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Grant Schema Permissions in Powershell

Grant Schema Permissions in Powershell

This is another excellent video that shows the power of powershell in SQL administration. I love this video because it’s a very common scenario Continue reading “Grant Schema Permissions in Powershell”

Author Sean McCownPosted on October 1, 2017October 25, 2017Categories Administration, Powershell

Powershell Profiles

Powershell Profiles

Here I finally address how to connect to SQL Server from powershell proper by adding the SQL Server snapins. Then I show you how Continue reading “Powershell Profiles”

Author Sean McCownPosted on October 1, 2017October 25, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Beginning Powershell for DBAs 2

Beginning Powershell for DBAs 2

This is the 2nd video in the schema series. Here I give you a really good reason to adopt schemas in your architectures. Hope Continue reading “Beginning Powershell for DBAs 2”

Author Sean McCownPosted on October 1, 2017October 25, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

Change SQL Server Job Owner

Change SQL Server Job Owner

This is a really cool method for changing SQL job owners or any job property I would imagine. It really simplifies it from using Continue reading “Change SQL Server Job Owner”

Author Sean McCownPosted on October 1, 2017December 21, 2017Categories Administration, Powershell, SecurityTags Administration, Powershell, Security

Beginning Programming with Powershell

Beginning Programming with Powershell

Have you ever wanted to learn how to code, but you don’t think you have enough knowledge to jump into a class? In this Continue reading “Beginning Programming with Powershell”

Author Sean McCownPosted on January 10, 2017October 25, 2017Categories Administration, PowershellTags Administration, Enterprise Administration, Powershell

BROWSE VIDEOS

By Subject

  • Administration
    • Backup and Restore
    • BCP
    • Optimization
    • Powershell
    • Other
  • Development
    • SSIS
    • TSQL
    • Other
  • Minion
    • Minion Enterprise
    • Minion Backup
    • Minion Reindex
    • Minion CheckDB

WEBSHOW

  • DBA’s@midnight
    • Season 1
    • Season 2
    • Season 3
    • Season 4

BROWSE CATEGORIES

  • Administration
  • Backup and Restore
  • BCP
  • DBAs@Midnight
  • Development
  • Events
  • HADR
  • Minion
  • Minion Backup
  • Minion CheckDB
  • Minion Enterprise
  • Minion Reindex
  • Optimization
  • Other
  • Other
  • Powershell
  • season 1
  • Security
  • SSIS
  • SSRS
  • TSQL
  • Uncategorized

BROWSE TAGS

.NET Administration AWS Backup/Restore BCP Clustering Config Development Enterprise Administration File issues File processing HADR HTML Index Maintenance Minion Backup Minion CheckDB Minion Enterprise Minion Reindex Modeling Office365 Performance Powershell Regex Reindex Replication S3 Script Task Security SMO Soft Skills SQL Saturday SSIS SSRS Stored Procedures T-SQL Troubleshooting Virtual Computing Visual Studio Windows

OUR WEBSITES


BLOGS

DBA Rant
The MidnightDBA Star
Minion Blog

  • About us
  • Links
  • FAQs
  • Contact
Copyright MidnightDBA