Tag: PowerShell

Video: Building Unconventional SQL Server Tools in PowerShell

Last week, on Wednesday (April 6th, 2016), I presented a session at the PowerShell and DevOps Global Summit 2016 on "Building Unconventional SQL Server Tools in PowerShell with Functions and Script Modules". The video from that presentation is now available: https://youtu.be/2rEzMWdTFDk Here's the abstract or synopsis for this presentation: "Have you ever had records from a SQL Server database table come up missing? Maybe someone or some process deleted them, but who really knows what happened Read more [...]

Write Dynamic Unit Tests for your PowerShell Code with Pester

I wrote a blog article on: "PowerShell Script Module Design: Placing functions directly in the PSM1 file versus dot-sourcing separate PS1 files" earlier this year and I've moved all of my PowerShell script modules to that design and while today's blog article isn't part of a series, that previous one is recommended reading so you're not lost when trying to understand what I'm attempting to accomplish. Most unit tests that I've seen created with Pester for testing PowerShell code are very specific, Read more [...]

Converting a SQL Server Log Sequence Number with PowerShell

As demonstrated in one of my previous blog articles "Determine who deleted SQL Server database records by querying the transaction log with PowerShell", someone or something has deleted records from a SQL Server database. You've used my Find-MrSqlDatabaseChange function to determine when the delete operation occurred based on information contained in either transaction log backups or the active transaction log: You're ready to perform point in time recovery Read more [...]

Pro Tips from the Trenches: The Resolve-Path PowerShell cmdlet

You're designing a reusable tool in PowerShell and decide a function is the most appropriate type of command to accomplish the task at hand. It will accept a FilePath parameter which will be used to specify both the path and filename to a destination file. The path should already exist, but the file may or may not already exist. For simplicity, I've stripped away the complexity so the problem is more apparent. This function validates that the parent path exists and then returns the absolute path Read more [...]

Run 350 Nano Server Virtual Machines on a Lenovo ThinkPad P50 with Hyper-V in Windows 10

If you're a frequent reader of my blog articles on this site, then you're already aware that I recently purchased a Lenovo ThinkPad P50 with a Xeon CPU, 64 GB of RAM, and upgraded it to SSD hard drives as shown in my previous blog article. I tweeted that it wouldn't be complete without a few PowerShell stickers: I received a response from Jeffrey Snover wanting to know how many Nano server VM's could be run on it: I took that as a challenge and decided to spin up as many Nano server Read more [...]

Determine the Packt Publishing Free eBook of the Day with PowerShell

First of all, let me state that I'm in no way affiliated with Packt Publishing other than being a customer. They offer a free eBook each day and that information is freely available on the Internet. Like any information on the web, it's publicly available and you can read it with a web browser or with something like PowerShell. As shown in the following example, a PowerShell one liner can be used to determine their free eBook of the day: This requires PowerShell Read more [...]

Use PowerShell to Add Active Directory Users to Specific Groups based on a CSV file

I recently responded to a post in a forum about adding Active Directory users to groups with PowerShell based on information contained in a CSV (Comma Separated Values file format). I thought I would not only share the scenario and solution that I came up with but also elaborate on adding additional functionality that may be desired. In this scenario, you’ve been provided with a CSV file that contains a list of Active Directory users and the groups that they should be a member of as shown in Read more [...]

Configuring the PowerShell ISE for use with Git and GitHub

The goal of this blog article is to configure the PowerShell ISE (Integrated Scripting Environment) so the management of Git version control can be performed from it. Most tutorials you'll find will attempt to lead you down the path of using SSH instead of HTTPS to synchronize your repositories to GitHub from the command-line but that's really over-complicated and unnecessary if you're using a Windows based machine. The client machine used in this blog article runs the 64 bit version of Windows Read more [...]

Video: Making the Leap from PowerShell One-Liners and Scripts to Advanced Functions and Script Modules

This past Tuesday, I presented a session for the Arizona PowerShell Users Group on “Making the Leap from PowerShell One-Liners and Scripts to Advanced Functions and Script Modules”. The video from that presentation is now available: https://youtu.be/2tPCNSJXicI The presentation materials including the code and a PDF copy of the slide deck can be downloaded from here. µ Read more [...]

How to install the new preview version of the PowerShell ISE

The PowerShell team released a new preview version of the PowerShell ISE (Integrated Scripting Environment) this week. This is the first time a new version of the PowerShell ISE has been released separately from a new version of the WMF (Windows Management Framework). This new approach reminds me of how they shipped the help separately from the WMF beginning with PowerShell version 3.0. Best of All, this new preview version of the ISE is a module which is distributed via the PowerShell Gallery Read more [...]

#PowerShell Script Module Design: Placing functions directly in the PSM1 file versus dot-sourcing separate PS1 files

So you've transitioned from writing PowerShell one-liners and scripts to creating reusable tools with functions and script modules. You may have started off by simply placing your functions in a PS1 file and dot-sourcing it. That leaves a lot to be desired though since it's a manual process and even if you've added some code to your profile to accomplish that task, the experience still isn't as good as it could be. Many of the short comings can be alleviated by simply placing your functions into Read more [...]

Building logic into PowerShell functions to nag users before their Active Directory password expires

This week I'm sharing a couple of PowerShell functions that are a work in progress to nag those users who seem to never want to change their passwords. I can't tell you how many times the help desk staff at one of the companies that I provide support for receives a call from a user who is unable to access email or other resources on the intranet. The problem? They have run their password down to the point where they arrive in the morning, log into their computer without issue, and during the day Read more [...]

Video: Demystifying Active Directory User Account Lockouts with PowerShell

A few months ago I created an audition video for Pluralsight on “Demystifying Active Directory User Account Lockouts with PowerShell” and I thought I would share that video with you, the readers of my blog site:

You can also find this video on my YouTube channel.

Happy New Year!


Use PowerShell to Determine Services with a StartType of Automatic or Manual with Trigger Start

Newer Windows operating systems have numerous services that are set to start automatically or manually with a triggered start. The following image is from a machine that's running Windows 10 Enterprise Edition (version 1511): The problem is when you're trying to determine whether or not all of the services that are set to start automatically are running or not. These trigger start services can't be filtered out using the Get-Service cmdlet or with WMI and they aren't necessarily suppose to Read more [...]

StartType property added to Get-Service in PowerShell version 5 build 10586 on Windows 10 version 1511

If you've used PowerShell for more than 5 minutes, then you probably have some experience with the Get-Service cmdlet. As you could have guessed if you didn't already know, the Get-Service cmdlet retrieves information about Windows services. Depending on what you're trying to accomplish, that particular cmdlet could leave a lot to be desired. Want to know if a service is running? No problem. Want to know what the startup type is for one or more services? Sorry, you can't accomplish that task with Read more [...]