Rolls back the active transaction. (Undo-Transaction)

   

# NAME
Undo-Transaction

# SYNOPSIS
Rolls back the active transaction.

# SYNTAX
Undo-Transaction [-Confirm] [-WhatIf] [<CommonParameters>]

# DESCRIPTION
The Undo-Transaction cmdlet rolls back the active transaction. When you roll back a transaction, the changes made by the commands in the transaction are discarded and the data is restored to its original form.

If the transaction includes multiple subscribers, an Undo-Transaction command rolls back the entire transaction for all subscribers.

By default, transactions are rolled back automatically if any command in the transaction generates an error. However, transactions can be started with a different rollback preference and you can use this cmdlet to roll back the active transaction at any time.

The Undo-Transaction cmdlet is one of a set of cmdlets that support the transactions feature in Windows PowerShell. For more information, see about_Transactions.

# PARAMETERS
-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actually executing the command.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

# INPUTS
None
You cannot pipe input to this cmdlet.

# OUTPUTS
None
This cmdlet does not return any output.

# NOTES

You cannot roll back a transaction that has been committed.

You cannot roll back any transaction other than the active transaction. To roll back a different, independent transaction, you must first commit or roll back the active transaction.

Rolling back the transaction ends the transaction. To use a transaction again, you must start a new transaction.

# EXAMPLE 1

C:\PS>undo-transaction

# Description
-----------
This command rolls back the current (active) transaction.

# EXAMPLE 2

C:\PS>cd hkcu:\software

PS HKCU:\Software> start-transaction
PS HKCU:\Software> new-item MyCompany -usetransaction
PS HKCU:\Software> undo-transaction

# Description
-----------
This command starts a transaction and then rolls it back. As a result, no changes are made to the registry.

# EXAMPLE 3

C:\PS>cd hkcu:\software

PS HKCU:\Software> start-transaction
PS HKCU:\Software> new-item MyCompany -usetransaction
PS HKCU:\Software> get-transaction

RollbackPreference SubscriberCount Status
------------------ --------------- -----
Error 1 Active

PS HKCU:\Software> start-transaction
PS HKCU:\Software> get-transaction

RollbackPreference SubscriberCount Status
------------------ --------------- -----
Error 2 Active

PS HKCU:\Software> undo-transaction
PS HKCU:\Software> get-transaction

RollbackPreference SubscriberCount Status
------------------ --------------- -----
Error 0 RolledBack

# Description
-----------
This example demonstrates that when any subscriber rolls back a transaction, the entire transaction is rolled back for all subscribers.

The first command changes the location to the HKCU:\Software registry key.

The second command starts a transaction.

The third command uses the New-Item cmdlet to create a new registry key. The command uses the UseTransaction parameter to include the change in the transaction.

The fourth command uses the Get-Transaction cmdlet to get the active transaction. Notice that the status is Active and the subscriber count is 1.

The fifth command uses the Start-Transaction command again. Typically,
starting a transaction while another transaction is in progress occurs when a script used by the main transaction includes its own complete transaction. (This example is done interactively so that you can examine it in stages.)

When you enter a Start-Transaction command while another transaction is in progress, the commands join the existing transaction as a new "subscriber" and the subscriber count is incremented.

The sixth command uses the Get-Transaction cmdlet to get the active transaction. Notice that the subscriber count is now 2.

The seventh command uses the Undo-Transaction cmdlet to roll back the transaction. This command does not return any objects.

The final command is a Get-Transaction command that gets the active (or in this case, the most recently active) transaction. The results show that the transaction is rolled back, and that the subscriber count is 0, showing that the transaction was rolled back for all subscribers.

RELATED LINKS
Online version: http://go.microsoft.com/fwlink/?LinkID=135268
about_Transactions
about_Providers
Start-Transaction
Get-Transaction
Complete-Transaction
Use-Transaction

C:\Windows>powershell get-help Use-Transaction -full

ColorConsole [Version 1.7.1000] PowerShell 2.0-Export
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2014 Microsoft Corporation.

OS: Windows-10 / Windows-8.1 & 8 / Windows-7 & Vista / Windows Server 2008-2016
»»»» ColorConsole



 


... Home  
... Impressum
... ColorConsole

... CMD
... Netsh-XP
... Netsh-7
... Netsh-Vista
... Powershell









Download the Windows 7 Starter, Home (Basic Premium), Professional und Ultimate!

... facebook.de
0.108
Ich kann nicht auf meinen Windows Server mit dem FTP-Browser, bzw dem Explorer, zugreifen. Warum?  / Was sind die Speicheroptionen im benutzerdefinierten Text?  / Print or export search result data list from Explorer in Win 7, 8, 8.1 (xls, txt, html, csv)!  / Hilfe, Windows 7 hat keine Spiele?  / Der Leistungsindex in Windows 8.1 / 10 fehlt?  / Create and mange user accounts in Windows 10?  / Ist die Remoteunterstützung bei Win-7 auch möglich?  / Windows 7 Benutzer beim Startbildschirm alle Benutzer anzeigen?  / How can I disable the seconds Pointer in the desktop Clock (Windows)?  / Difference between Save Current State and Save Current State at Desktop Item?  / Run directly minimized to tray without to see the main window?  / Wie kann Textfeldauswahl für Einzel-Hotkey (Tastenkombination) erstellen?  /