Transactions/Use-Transaction in PowerShell 7 not available

Hi PS community,

I am new to PS and started learning few months back and I am going through some lab exercises from the book “The PowerShell Practice Primer” From Jeff Hicks.

There was one exercise and the question was “What PSProvider supports transactions?” and I came up with the following command:

Get-PSProvider | where {$_.Capabilities -like ‘transactions’}

Turns out I was getting nothing on return and I found odd, then I looked at the solution and He wrote in PowerShell v7 this feature is gone.

Then I tested in the PS 5.1 that comes with Windows and it does indeed work.

It seems the only PSDrive that used Transactions were the Registry but does anybody know why was that removed in v7 ?

I even found a thread on GitHub about it but does not say an explanation behind this:

Missing PS shipped cmdlets · Issue #11732 · PowerShell/PowerShell (github.com)

Hi, welcome to the forum :wave:

Windows PowerShell 5.1 was built on the .NET Framework.
Later PowerShell versions, which are cross-platform, are built on .NET Core which does not have all of the features that are present in the .NET Framework.

I would speculate that as PS Providers are .NET programs, it’s likely that .NET Core does not support transactions and as such the Transaction cmdlets could not be implemented.
This post would appear to confirm my thinking:

It looks like at the time we started on PSCore6, System.Transactions wasn’t available, so those cmdlets were removed. It appears that namespace is back in 3.1, so we could bring them back in 7.1.

2 Likes

That makes sense Matt, thanks for the reply!