Press "Enter" to skip to content

Category: Powershell

The Library of Congress Control Number (LCCN)

Robert Cain continues a series on book archival:

This is part of my ongoing series on my ArcaneBooks project. The goal is to provide a module to retrieve book data via provided web APIs. In the SEE ALSO section later in this post I’ll provide links to previous posts which cover the background of the project, as well as how to use the OpenLibrary APIs to get data based on the ISBN.

In this post I will provide an overview of using the Library of Congress API to get data based on the LCCN, short for Library of Congress Control Number.

This has been an interesting series to watch, as it’s a practical application of non-work use of a series of practical development skills.

Comments closed

Putting tempdb on an Azure VM Temp Disk

Daniel Hutmacher uses a temp disk for a temp database:

Almost all Azure virtual machine sizes come with a temporary disk. The temporary disk is a locally attached SSD drive that comes with a couple of desirable features if you’re installing a SQL Server on your VM:

  • Because it is locally attached, it has lower latency than regular disks.
  • IO and storage are not billed like regular storage.

As the name implies, the temporary disk is not persistent, meaning that it will be wiped if you shut down your VM or if the VM moves to another VM host (as part of maintenance or troubleshooting). For that reason, we never want to put anything on the temporary disk that we need to keep.

I’d say this was a lot more popular several years ago, back when spinning disk was the default for Azure storage. There can still be benefits from doing this, though if you’re using Premium storage with high IOPS, the biggest remaining benefit is around latency.

Comments closed

Digging into the OpenLibrary ISBN API

Robert Cain is looking for a book:

The format of the Advanced API is slightly different from the simple. Here is template.

https://openlibrary.org/api/books?bibkeys=ISBN:[ISBN Goes Here]&jscmd=data&format=json"

You will replace the [ISBN Goes Here] text with the ISBN number you want to look up. Be aware this can only be digits, you must remove any spaces, dashes, or other characters.

Let’s look at a code example of calling the API and getting all its properties.

Click through for examples and how you can use Powershell to parse the results.

Comments closed

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