PowerShell/PowerShell · error · NotImplementedException

RollbackPreference

Error message

RollbackPreference

What it means

RollbackPreference is a CoreCLR stub property (RollbackSeverity enum) that always throws NotImplementedException. It is part of the internal Transaction stub class that preserves the full-framework API surface without providing functionality, since System.Transactions is absent from CoreCLR.

Source

Thrown at src/System.Management.Automation/CoreCLR/CorePsStub.cs:106

        /// <summary>
        /// Determines if the last transaction has been rolled back.
        /// </summary>
        internal bool IsLastTransactionRolledBack
        {
            get
            {
                throw new NotImplementedException("IsLastTransactionRolledBack");
            }
        }

        /// <summary>
        /// Gets the rollback preference for the active transaction.
        /// </summary>
        internal RollbackSeverity RollbackPreference
        {
            get
            {
                throw new NotImplementedException("RollbackPreference");
            }
        }

        /// <summary>
        /// Called by engine APIs to ensure they are protected from
        /// ambient transactions.
        /// </summary>
        /// <remarks>
        /// Always return null in CoreCLR
        /// </remarks>
        internal static IDisposable GetEngineProtectionScope()
        {
            return null;
        }

        /// <summary>
        /// Aborts the current transaction, no matter how many subscribers are part of it.
        /// </summary>

View on GitHub (pinned to 3ff3c711bf)

Solutions

  1. Guard with a platform/framework check before reading RollbackPreference.
  2. Use compile-time conditionals to exclude transaction-preference reads on CoreCLR.
  3. Default to a sensible RollbackSeverity value (e.g., Error) in CoreCLR fallback code.

Example fix

// before
var pref = transaction.RollbackPreference;

// after
RollbackSeverity pref = RollbackSeverity.Error;
#if !CORECLR
pref = transaction.RollbackPreference;
#endif
Defensive patterns

Strategy: fallback

Validate before calling

// Guard rollback preference access with platform check
RollbackSeverity GetRollbackPreferenceSafe()
{
#if !CORECLR
    return transaction.RollbackPreference;
#else
    return RollbackSeverity.Error; // CoreCLR: default fallback
#endif
}

Try / catch

try { var pref = transaction.RollbackPreference; }
catch [System.NotImplementedException] { pref = RollbackSeverity.Error; // CoreCLR fallback }

Prevention

When it happens

Trigger: Any code path in PowerShell Core/CoreCLR that reads the Transaction.RollbackPreference property getter.

Common situations: Transaction-aware cmdlets or modules running on PowerShell 7; code that inspects rollback severity configuration; ported full-framework code that references transaction settings.

Related errors


AI-assisted analysis of PowerShell/PowerShell@3ff3c711bf (2026-08-13). Data as JSON: /api/errors/42a9984f8c5afcc0. Report an issue: GitHub.