Press "Enter" to skip to content

Category: Powershell

OneDrive and Disappearing Powershell Modules

Robert Cain diagnoses a weird issue:

I was having a weird problem with PowerShell, while working on my ArcaneBooks project. I would install a module, and it would work fine at first. I could see the module when I used Get-Module -ListAvailable, and use it.

The problem occurred when I closed the terminal (whether the Windows Terminal or in VSCode), then reopened it. The module had vanished! It was no longer there, I would get an error if I tried to import it, and Get-Module -ListAvailable would no longer show it. I could reinstall, it’d be there, but again when I closed the terminal and reopened it would be gone.

Read on to learn what OneDrive was doing and how Robert at least got it to stop doing that.

Comments closed

What-If Operations in Powershell

Chad Callihan looks at one of my favorite features in Powershell:

We’ve all had moments of instant regret. Maybe it was missing that WHERE clause when executing a SQL statement or seeing something like “500 rows affected” when expecting only 1. These are sinking feelings we never want to experience again.

To avoid that pain, SQL Server has BEGIN/ROLLBACK/COMMIT that you can use to help check your work. Did you know PowerShell also has a helpful switch called WhatIf to preview changes before they’re applied?

This does take a bit of effort to implement in your custom modules, but the fact that the language has this concept explicitly laid out is a smart idea.

Comments closed

Working with Powershell Objects

Max Trinidad familiarizes us with objects in Powershell:

Working with PSObjects is essential to anyone using PowerShell. Especially, when there’s a need to extend the object to provide useful information.

Remember, the best way to get familiar with the PowerShell object(‘s)… (AKA PSOBject, .NET Object) is to use the ‘Get-Member’ Cmdlet.

Click through for several tips on how to add custom properties and learn more about what’s available on objects along the way.

Comments closed

Enabling Powershell Constrained Mode

Patrick Gruenauer slips on the straightjacket:

In this blog post I am going to show you how to enable the PowerShell Constrained Mode. What is the Constrained Mode? Microsoft explains this as follows:

Click through for that definition, as well as a demonstration and bit more explanation. It seems that there’s a specific use case for constrained mode, and it’s not one most of us are likely to work with.

Comments closed

Using the OpenLibrary ISBN API with Powershell

Robert Cain has been working on a neat project:

In this post we’ll begin with an overview of what an ISBN is. We’ll then talk about the website that will be the source for our data. It has two different web APIs (Application Programming Interface) that we can use. We’ll discuss one here, then in the next blog post cover the advanced version.

First though, if you haven’t read the introductory post in this series, The ArcaneBooks Project – An Introduction, I’d highly recommend doing so as it lays the foundation for why and how this project to get ISBN data originated.

Robert is building this up over a series of posts, so stay tuned.

Comments closed

Database Backups with dbatools

Chad Callihan backs that database up:

Keeping on the recent PowerShell trend, let’s use PowerShell to accomplish a primary task of any database administrator: backups. With PowerShell and dbatools, you can do a simple backup or add a range of options to fit your needs.

I’d also like to call out that it’s really easy to set configuration options with dbatools, such as buffer count and max transfer size.

Comments closed

Unmasking Dynamic Data Masking via Powershell

Jana Sattainathan needs to see all the details:

Today, I had to unmask all the columns I had helped mask using Dynamic Data Masking. This simple post assumes that you are a privileged user with the ability to drop “Column Masking”!

In other words, this isn’t exploiting the mechanics of Dynamic Data Masking to view data you shouldn’t be able to; it’s about removing Dynamic Data Masking from columns with it enabled.

Comments closed

Investigating Powershell Object Members

Jeffrey Hicks wants to know what he can do:

A few weeks ago, I was working on content for a new PowerShell course for Pluralsight. The subject was objects. We all know the importance of working with objects in PowerShell. Hopefully, you also know that the output you get on your screen from running a PowerShell command is not the whole story. Formatted presentation is separate from the underlying objects in the pipeline. That’s why it is important to know how to use Get-Member to discover how an object is defined.

But, as Jeffrey points out, this doesn’t work for static members. Read on to learn what does.

Comments closed

Scaling Multiple Azure SQL DBs on a Single Server

Laith Ayesh has a script for us:

In a few scenarios, you might need to scale multiple databases on a logical server (not part of elastic pool) at once, the azure portal only allows you to scale each database individually. This can be achieved using the following PowerShell script:

just modify the parameters like SubID, the resource group and server name and then pick the service tier you want and run the script:

Click through for the Powershell script and an important note.

Comments closed

Working with IP Addresses in Powershell

Bill Kindle takes us through several Powershell cmdlets:

A common SysAdmin task involves managing a PowerShell IP configuration. Typically, one performs this task using the GUI, which is OK. But PowerShell can do the same job and more, which you can put into scripting.

In this tutorial, you will learn how to use a few network management cmdlets in PowerShell to help manage a Windows host’s IP address, gateway, and DNS settings.

Understanding how to do this becomes even more important if you’re running Windows Server Core, where you don’t have too many choices other than rolling with Powershell.

Comments closed