Scripting. Powershell, VMware, Windows, Active Directory & Exchange. All that kind of stuff…..
RSS icon Email icon Home icon
  • PowerShell 2.0: One Cmdlet at a Time #79 Complete-Transaction

    Posted on March 18th, 2010 Jonathan Medd No comments

    Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Complete-Transaction cmdlet.

    What can I do with it?

    PowerShell 2.0 introduces new functionality in the form of transactions. By grouping together a set of commands to form a transaction they can either all be committed or all rolled back depending on success.

    Complete-Transaction commits a transaction which has been kicked off with Start-Transaction.

    Example:

    A good example of a possible use for transactions is within the registry. Change directory into the registry provider. Begin a new transaction and use the New-Item and New-ItemProperty cmdlets to potentially create entries within the registry. Use Complete-Transaction to commit these changes.

    cd HKLM:\Software
    Start-Transaction
    New-Item Test -UseTransaction
    New-ItemProperty Test -Name TestKey -Value 1000 -UseTransaction
    Complete-Transaction

    Complete-Transaction

    You will notice that after completing the transaction the changes have been made in the registry.

    Complete-Transaction2

    How could I have done this in PowerShell 1.0?

    Transactional functionality was not available in PowerShell 1.0.

    1000 things 1% better!

    Leave a reply