February 2019
Intermediate to advanced
626 pages
15h 51m
English
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, as shown in the following code:
PS> Get-PSProviderName 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}
A transaction may be created as follows:
Start-Transaction $path = 'HKCU:\TestTransaction' New-Item $path -ItemType Key -UseTransaction Set-ItemProperty $path -Name 'Name' -Value 'Transaction' -UseTransaction ...
Read now
Unlock full access