{"id":51223,"date":"2010-02-22T00:01:00","date_gmt":"2010-02-22T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2010\/02\/22\/hey-scripting-guy-how-can-i-use-transactions-in-windows-powershell-2-0\/"},"modified":"2010-02-22T00:01:00","modified_gmt":"2010-02-22T00:01:00","slug":"hey-scripting-guy-how-can-i-use-transactions-in-windows-powershell-2-0","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/hey-scripting-guy-how-can-i-use-transactions-in-windows-powershell-2-0\/","title":{"rendered":"Hey, Scripting Guy! How Can I Use Transactions in Windows PowerShell 2.0?"},"content":{"rendered":"<p class=\"MsoNormal\"><a class=\"addthis_button\" href=\"http:\/\/www.addthis.com\/bookmark.php?v=250&amp;pub=scriptingguys\"><img decoding=\"async\" alt=\"Bookmark and Share\" src=\"http:\/\/s7.addthis.com\/static\/btn\/v2\/lg-share-en.gif\" width=\"125\" height=\"16\"><\/a>&nbsp;<\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p><img decoding=\"async\" title=\"Hey, Scripting Guy! Question\" border=\"0\" alt=\"Hey, Scripting Guy! Question\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" height=\"34\"><\/p>\n<p class=\"MsoNormal\">Hey, Scripting Guy! I am primarily a database guy, but I have started using Windows PowerShell because of the Windows PowerShell cmdlets for SQL Server 2008. One thing I like about databases is that I can create a transaction. For example, I can begin a transaction, transfer money from one account to another account, check that the transfer completed properly, and then delete the money from the original account. If the transfer does not complete properly, I roll back the transaction and make no changes. I wish I could do something like that in Windows PowerShell. <\/p>\n<p class=\"MsoNormal\">&#8212; TL<\/p>\n<p class=\"MsoNormal\">\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><img decoding=\"async\" title=\"Hey, Scripting Guy! Answer\" border=\"0\" alt=\"Hey, Scripting Guy! Answer\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" height=\"34\">Hello TL, <\/p>\n<p class=\"MsoNormal\">Microsoft Scripting Guy Ed Wilson here. Your e-mail message brings up a conversation I had with the Scripting Wife many years ago when we were getting ready to leave for <a href=\"http:\/\/en.wikipedia.org\/wiki\/Kauai,_Hawaii\"><font face=\"Segoe\">Kauai, Hawaii<\/font><\/a>. She went online to our bank to transfer some funds from savings to checking so that we would have more direct access to cash if we needed it (we did; Hawaii is expensive when you come from the southern United States). Because this was a long time ago, the Scripting Wife was not as Internet savvy as she is today. The Internet connection to our bank&rsquo;s Web site failed in the process of moving the money, and she began to panic. <\/p>\n<p class=\"MsoNormal\">At that time, I was doing a lot of database work and had even taught several SQL Server certification classes at the local Microsoft Training Center. I calmly explained to her about the <a href=\"http:\/\/en.wikipedia.org\/wiki\/ACID\"><font face=\"Segoe\">ACID principle<\/font><\/a> that governs transactional database operations and exclaimed that we would simply check our account balances when we arrived in Lihue. If the bank&rsquo;s database team was so lame as to not follow such a basic principle, we would be changing banks. The bank was smart enough to initiate a transaction at the beginning of the operation, and because the Internet connection failed before completion, the transaction rolled back and the money was still in the savings account. <\/p>\n<p class=\"MsoNormal\">The following picture of a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Honu\"><font face=\"Segoe\">honu<\/font><\/a> is one that I took while scuba diving during that trip. <\/p>\n<p class=\"Fig-Graphic\"><img decoding=\"async\" title=\"Image of a honu\" alt=\"Image of a honu\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/qanda\/hsg\/2010\/february\/hey0222\/hsg-02-22-10-01.jpg\" width=\"600\" height=\"450\"><\/p>\n<p class=\"Fig-Graphic\">\n<p>&nbsp;<\/p>\n<\/p>\n<p class=\"MsoNormal\">TL, the first thing you need to know about using transactions in Windows PowerShell 2.0 is that it requires you to be running a minimal operating system version. The minimum operating system version that supports transactions is Windows Vista. Unfortunately, you can start a transaction on Windows XP, but Windows PowerShell does not generate an error until you attempt to use the transaction. The following image illustrates this.<\/p>\n<p class=\"Fig-Graphic\"><img decoding=\"async\" title=\"Image of error generated by Windows PowerShell\" alt=\"Image of error generated by Windows PowerShell\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/qanda\/hsg\/2010\/february\/hey0222\/hsg-02-22-10-02.jpg\" width=\"600\" height=\"501\"><\/p>\n<p class=\"Fig-Graphic\">\n<p>&nbsp;<\/p>\n<\/p>\n<p class=\"MsoNormal\">The next thing you need to know about using transactions in Windows PowerShell 2.0 is that the provider must support transactions. Before you check for transaction support, you may wish to load any modules you may have installed. Windows PowerShell 2.0 ships with several default modules, and other modules are available for download from <a href=\"http:\/\/www.codeplex.com\/site\/search?projectSearchText=powershell%20module\">CodePlex<\/a> and other places. In addition, we have been writing our own module during the <a href=\"http:\/\/blogs.technet.com\/heyscriptingguy\/archive\/tags\/Weekend+Scripter\/default.aspx\"><font face=\"Segoe\">Weekend Scripter series<\/font><\/a>. To see which modules are loaded, use the <b>Get-Module<\/b> cmdlet. To see available modules, use the <b>Get-Module<\/b> cmdlet with the <b>&ndash;listavailable<\/b> parameter. The code list that follows illustrates this:<\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">PS C:&gt; Get-Module<br \/>PS C:&gt; Get-Module -ListAvailable<\/p>\n<p>ModuleType Name<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>ExportedCommands<br \/>&#8212;&#8212;&#8212;- &#8212;-<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>Script<span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>BasicFunctions<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{}<br \/>Script<span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>ConversionModuleV4<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{}<br \/>Script<span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>DotNet<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{}<br \/>Manifest<span>&nbsp;&nbsp; <\/span>FileSystem<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{}<br \/>Manifest<span>&nbsp;&nbsp; <\/span>IsePack<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{}<br \/>Manifest<span>&nbsp;&nbsp; <\/span>PowerShellPack<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{}<br \/>Manifest<span>&nbsp;&nbsp; <\/span>PSCodeGen<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{}<br \/>Manifest<span>&nbsp;&nbsp; <\/span>PSImageTools<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{}<br \/>Manifest<span>&nbsp;&nbsp; <\/span>PSRSS<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{}<br \/>Manifest<span>&nbsp;&nbsp; <\/span>PSSystemTools<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{}<br \/>Manifest<span>&nbsp;&nbsp; <\/span>PSUserTools<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{}<br \/>Manifest<span>&nbsp;&nbsp; <\/span>TaskScheduler<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{}<br \/>Manifest<span>&nbsp;&nbsp; <\/span>WPK<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{}<br \/>Manifest<span>&nbsp;&nbsp; <\/span>ActiveDirectory<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{}<br \/>Manifest<span>&nbsp;&nbsp; <\/span>AppLocker<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{}<br \/>Manifest<span>&nbsp;&nbsp; <\/span>BitsTransfer<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{}<br \/>Manifest<span>&nbsp;&nbsp; <\/span>FailoverClusters<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{}<br \/>Manifest<span>&nbsp;&nbsp; <\/span>GroupPolicy<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{}<br \/>Manifest<span>&nbsp;&nbsp; <\/span>NetworkLoadBalancingCl&#8230; {}<br \/>Manifest<span>&nbsp;&nbsp; <\/span>PSDiagnostics<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span>&nbsp;&nbsp;&nbsp;&nbsp;<\/span>{}<br \/>Manifest<span>&nbsp;&nbsp; <\/span>TroubleshootingPack<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{}<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoNormal\">After you have found your list of available modules, you may wish to load all of the modules at once. You can do this by piping the results of your <b>Get-Module &ndash;Listavailable<\/b> command to the <b>Import-Module<\/b> cmdlet. Use the <b>Get-Module<\/b> cmdlet to ensure that the modules import properly. The command seen here illustrates this technique:<\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">PS C:&gt; Get-Module -ListAvailable | Import-Module<br \/>PS C:&gt; Get-Module<\/p>\n<p>ModuleType Name<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>ExportedCommands<br \/>&#8212;&#8212;&#8212;- &#8212;-<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>Script<span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>BasicFunctions<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{Get-ComputerInfo, Get-OptimalSize}<br \/>Script<span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>ConversionModuleV4<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{ConvertTo-Feet, ConvertTo-Miles, ConvertTo-Pounds, ConvertTo-Meters&#8230;}<br \/>Script<span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>PowerShellPack<span>&nbsp;&nbsp;&nbsp; <\/span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span>{New-ByteAnimationUsingKeyFrames, New-TiffBitmapEncoder, New-Viewbox, Ne&#8230;<br \/>Script<span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>PSCodeGen<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{New-Enum, New-ScriptCmdlet, New-PInvoke}<br \/>Script<span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>PSImageTools<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{Add-CropFilter, Add-RotateFlipFilter, Add-OverlayFilter, Set-ImageFilte&#8230;<br \/>Script<span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>PSRss<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{Read-Article, New-Feed, Remove-Article, Remove-Feed&#8230;}<br \/>Script<span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>PSSystemTools<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{Test-32Bit, Get-USB, Get-OSVersion, Get-MultiTouchMaximum&#8230;}<br \/>Script<span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>PSUserTools<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{Start-ProcessAsAdministrator, Get-CurrentUser, Test-IsAdministrator, Ge&#8230;<br \/>Script<span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>TaskScheduler<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{Remove-Task, Get-ScheduledTask, Stop-Task, Add-TaskTrigger&#8230;}<br \/>Script<span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>WPK<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{Get-DependencyProperty, New-ModelVisual3D, New-DiscreteVector3DKeyFrame&#8230;<br \/>Manifest<span>&nbsp;&nbsp; <\/span>ActiveDirectory<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{Set-ADOrganizationalUnit, Get-ADDomainControllerPasswordReplicationPoli&#8230;<br \/>Manifest<span>&nbsp;&nbsp; <\/span>AppLocker<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{Get-AppLockerPolicy, Get-AppLockerFileInformation, Test-AppLockerPolicy&#8230;<br \/>Manifest<span>&nbsp;&nbsp; <\/span>BitsTransfer<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{Start-BitsTransfer, Remove-BitsTransfer, Resume-BitsTransfer, Get-BitsT&#8230;<br \/>Manifest<span>&nbsp;&nbsp; <\/span>FailoverClusters<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{Set-ClusterParameter, Get-ClusterParameter, Stop-ClusterNode, Stop-Clus&#8230;<br \/>Manifest<span>&nbsp;&nbsp; <\/span>GroupPolicy<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span>{Get-GPStarterGPO, Get-GPOReport, Set-GPInheritance, Restore-GPO&#8230;}<br \/>Manifest<span>&nbsp;&nbsp; <\/span>NetworkLoadBalancingCl&#8230; {Stop-NlbClusterNode, Remove-NlbClusterVip, New-NlbClusterIpv6Address, S&#8230;<br \/>Script<span>&nbsp;&nbsp;&nbsp;&nbsp; <\/span>PSDiagnostics<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{Enable-PSTrace, Enable-WSManTrace, Start-Trace, Disable-PSWSManComb\nined&#8230;<br \/>Manifest<span>&nbsp;&nbsp; <\/span>TroubleshootingPack<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{Get-TroubleshootingPack, Invoke-TroubleshootingPack}<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoNormal\">Now that you have imported all of your modules, use the <b>Get-PSProvider<\/b> cmdlet to see which Windows PowerShell providers support transactions. This is shown here:<\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">PS C:&gt; Get-PSProvider<\/p>\n<p>Name<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Capabilities<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Drives<br \/>&#8212;-<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>&#8212;&#8212;&#8212;&#8212;<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>&#8212;&#8212;<br \/>WSMan<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Credentials<span>&nbsp; <\/span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span>{WSMan}<br \/>Alias<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>ShouldProcess<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{Alias}<br \/>Environment<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>ShouldProcess<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{Env}<br \/>FileSystem<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Filter, ShouldProcess<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span>{C, E, Desktop, Programs&#8230;}<br \/>Function<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>ShouldProcess<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{Function}<br \/>Registry<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>ShouldProcess, Transactions<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{HKLM, HKCU}<br \/>Variable<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>ShouldProcess<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span>{Variable}<br \/>Certificate<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>ShouldProcess<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{cert}<br \/>ActiveDirectory<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Include, Exclude, Filter, ShouldProcess, Crede&#8230; {}<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoNormal\">The capabilities of the <b>ActiveDirectory<\/b> provider are truncated. To see all of the capabilities of the <b>ActiveDirectory<\/b> provider, pipe the results to <b>Format-List<\/b> (<b>fl<\/b> is the alias), as shown here:<\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">PS C:&gt; Get-PSProvider act* | fl capabilities<\/p>\n<p>Capabilities : Include, Exclude, Filter, ShouldProcess, Credentials<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoNormal\">It would seem that the only provider that supports transactions is the registry provider. To make certain of our results, we can use the <b>Where-Object<\/b> cmdlet (<b>?<\/b> Is the alias) to filter out the results obtained by the <b>Get-PSProvider<\/b> cmdlet, as shown here:<\/p>\n<p class=\"CodeBlock\"><span><font face=\"Lucida Sans Typewriter\">PS C:&gt; Get-PSProvider | Where-Object { $_.capabilities -match &#8216;transactions&#8217;}<\/p>\n<p>Name<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Capabilities<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>Drives<br \/>&#8212;-<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>&#8212;&#8212;&#8212;&#8212;<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>&#8212;&#8212;<br \/>Registry<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>ShouldProcess, Transactions<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span>{HKLM, HKCU}<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\">TL, that is all there is to understanding transactions in Windows PowerShell. Tomorrow, we will continue working with transactions. <\/p>\n<p class=\"MsoNormal\">If you want to know exactly what we will be looking at tomorrow, follow us on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> or <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\">Facebook<\/a>. If you have any questions, send e-mail to\nus at <a href=\"http:\/\/blogs.technet.commailto:scripter@microsoft.com\" target=\"_blank\"><font face=\"Segoe\">scripter@microsoft.com<\/font><\/a> or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p class=\"MsoNormal\">\n<p>&nbsp;<\/p>\n<\/p>\n<p><b><span>Ed Wilson and Craig Liebendorfer, Scripting Guys<\/p>\n<p><\/span><\/b><\/p>\n<p><b><span><\/span><\/b>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; &nbsp; Hey, Scripting Guy! I am primarily a database guy, but I have started using Windows PowerShell because of the Windows PowerShell cmdlets for SQL Server 2008. One thing I like about databases is that I can create a transaction. For example, I can begin a transaction, transfer money from one account to another [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[51,3,45],"class_list":["post-51223","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-getting-started","tag-scripting-guy","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>&nbsp; &nbsp; Hey, Scripting Guy! I am primarily a database guy, but I have started using Windows PowerShell because of the Windows PowerShell cmdlets for SQL Server 2008. One thing I like about databases is that I can create a transaction. For example, I can begin a transaction, transfer money from one account to another [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/51223","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=51223"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/51223\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=51223"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=51223"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=51223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}