Transactions
A transaction allows a set of changes to be grouped together and committed at the same time. Transactions are only supported under Windows PowerShell.
The registry provider supports transactions in Windows, as shown in the following code:
PS> Get-PSProvider
Name Capabilities Drives
---- ------------ ------
Registry ShouldProcess, Transactions {HKLM, HKCU}
Alias ShouldProcess {Alias}
Environment ShouldProcess {Env}
FileSystem Filter, ShouldProcess, Credentials {B, C, D}
Function ShouldProcess {Function}
Variable ShouldProcess {Variable}
You can create a transaction as follows:
Start-Transaction
$path = 'HKCU:\TestTransaction'
New-Item $path -ItemType Key -UseTransaction
Set-ItemProperty $path -Name 'Name' -Value...