├── .gitattributes ├── 0 - Soft skills.ps1 ├── 1 - Hard skills.ps1 ├── 2 - Entering the debugger without breakpoints.ps1 ├── 3 - Entering the debugger with Wait-Debugger.ps1 ├── 4 - Debugging with DebugPx.ps1 ├── 5 - More Debugging with DebugPx.ps1 ├── 6 - Advanced Debugging with DebugPx.ps1 ├── 7 - Editing and debugging jobs.ps1 ├── 8 - Attaching to a remote PowerShell host and debugging runspaces.ps1 ├── Abstract.md ├── LICENSE ├── README.md └── TMW06 - Become a PowerShell Debugging Ninja!.pptx /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set default behaviour, in case users don't have core.autocrlf set. 2 | * text=auto 3 | 4 | # Explicitly declare text files we want to always be normalized and converted 5 | # to native line endings on checkout. 6 | *.md text 7 | *.gitattributes text 8 | 9 | # Declare files that will always have CRLF line endings on checkout. 10 | *.ps1 text eol=crlf 11 | *.psm1 text eol=crlf 12 | *.psd1 text eol=crlf 13 | *.psc1 text eol=crlf 14 | *.ps1xml text eol=crlf 15 | *.clixml text eol=crlf 16 | *.xml text eol=crlf 17 | *.txt text eol=crlf 18 | -------------------------------------------------------------------------------- /0 - Soft skills.ps1: -------------------------------------------------------------------------------- 1 | ############################### 2 | # 3 | # Debugging basics: soft skills 4 | # 5 | ############################### 6 | 7 | function Reset-Error { 8 | $global:Error.Clear() 9 | $global:ErrorView = 'NormalView' 10 | # This is ISE-specific 11 | $psISE.Options.ErrorForegroundColor = '#FFFF0000' 12 | } 13 | Reset-Error 14 | 15 | # Generate an error 16 | function Show-Error {Get-Item C:\doesNotExist.txt} 17 | Show-Error 18 | 19 | # Make errors easier to read by changing the color 20 | $psISE.Options.ErrorForegroundColor = [System.Windows.Media.Colors]::Chartreuse 21 | Show-Error 22 | 23 | # TALK TO THE BEAR! 24 | # (or your puppy or a rubber duck or your Xamarin monkey or some other stuffed 25 | # animal that you keep hidden in your office) 26 | 27 | # This is a *proven* technique, and it really, really works. 28 | 29 | # Seriously. 30 | 31 | # There's a reason why people talk to themselves. 32 | 33 | # Priming the pump 34 | function Initialize-Error { 35 | $Error.Clear() 36 | (1..20).foreach{ 37 | switch (1..3 | Get-Random) { 38 | 1 { 39 | Get-Process -Name DoesNotExist 40 | } 41 | 2 { 42 | function C { 43 | # [System.Math]::Pow accepts two doubles 44 | [System.Math]::Pow(10, 'Two') 45 | } 46 | function B { 47 | C 48 | } 49 | function A { 50 | try { 51 | B 52 | } catch { 53 | } 54 | } 55 | A 56 | } 57 | 3 { 58 | $ErrorActionPreference = 'SilentlyContinue' 59 | Get-Process $pid 60 | } 61 | } 62 | } 63 | } 64 | Initialize-Error *> $null 65 | 66 | # All errors are stored in: 67 | $Error 68 | 69 | # How to make it less overwhelming (and prioritized and actionable) 70 | $Error ` 71 | | Group-Object ` 72 | | Sort-Object -Property Count -Descending ` 73 | | Format-Table -Property Count,Name -AutoSize 74 | 75 | # What about specific error details? 76 | $Error[0] | Format-List * 77 | 78 | # Use the Force, Luke! 79 | $Error[0] | fl * -Force 80 | 81 | # When the top level information isn't clear, go deep 82 | $Error[0].Exception 83 | $Error[0].Exception | fl * -Force 84 | $Error[0].Exception.InnerException | fl * -Force 85 | 86 | # If you don't like having to use -Force all the time, 87 | # community modules like my FormatPx can help 88 | 89 | # Leverage the stack traces 90 | $Error[0].ScriptStackTrace # For locations in PowerShell functions/scripts 91 | $Error[0].Exception.StackTrace # For locations in compiled cmdlets/dlls 92 | 93 | # Clean up behind yourself as you deal with errors 94 | $Error.Remove($Error[0]) # Remove a specific error 95 | $Error.RemoveAt(0) # Remove by index 96 | $Error.RemoveRange(0,10) # Remove by index + count 97 | $Error.Clear() # Clear the $Error collection 98 | 99 | # An important note about error handling: use try/catch to ensure terminating 100 | # errors actually terminate. 101 | 1/0; Write-Host 'Will this run?' -ForegroundColor Cyan 102 | function Test-Something { 103 | [cmdletbinding()] 104 | param() 105 | $callerErrorActionPreference = $ErrorActionPreference 106 | try { 107 | 1/0; Write-Host 'Will this run?' -ForegroundColor Cyan 108 | } catch { 109 | Write-Error -ErrorRecord $_ -ErrorAction $callerErrorActionPreference 110 | } 111 | } 112 | function Test-Something2 { 113 | [cmdletbinding()] 114 | param() 115 | try { 116 | 1/0; Write-Host 'Will this run?' -ForegroundColor Cyan 117 | } catch { 118 | throw 119 | } 120 | } 121 | # Compare Test-Something (clean error identifying the source line where it happened in the calling script) 122 | Test-Something 123 | # to Test-Something2 (error showing internals that doesn't identify the source line at all) 124 | Test-Something2 125 | # Now compare ErrorAction control over the Test-Something function 126 | Test-Something -ErrorAction SilentlyContinue; Write-Host 'This should appear' -ForegroundColor Green 127 | Test-Something -ErrorAction Stop; Write-Host 'This should not appear' -ForegroundColor Cyan 128 | # to the same control over Test-Something2 129 | Test-Something2 -ErrorAction SilentlyContinue; Write-Host 'This should appear' -ForegroundColor Green 130 | Test-Something2 -ErrorAction Stop; Write-Host 'This should not appear' -ForegroundColor Cyan 131 | -------------------------------------------------------------------------------- /1 - Hard skills.ps1: -------------------------------------------------------------------------------- 1 | ############################### 2 | # 3 | # Debugging basics: hard skills 4 | # 5 | ############################### 6 | 7 | function C { 8 | $x = 3 9 | Write-Host 'Initializing C...' -ForegroundColor Cyan 10 | [System.Math]::Pow(10,'Two') 11 | Write-Host 'Why doesn''t this message show up?' -ForegroundColor Cyan 12 | } 13 | function B { 14 | $x = 2 15 | C 16 | } 17 | function A { 18 | try { 19 | $x = 1 20 | B 21 | } catch { 22 | # In practice, you should almost never do this! Empty 23 | # catch blocks like this swallow _all_ errors! 24 | } 25 | } 26 | A 27 | 28 | # TIP! After learning visual line breakpoints, experiment with more advanced 29 | # breakpointing features like command and variable breakpoints (visible in 30 | # VS Code, not visible in ISE), and making breakpoints conditional. See 31 | # Get-Help Set-PSBreakpoint -Full for more details about these important 32 | # capabilities. -------------------------------------------------------------------------------- /2 - Entering the debugger without breakpoints.ps1: -------------------------------------------------------------------------------- 1 | ################################################# 2 | # 3 | # PSv5: Entering the debugger without breakpoints 4 | # 5 | ################################################# 6 | 7 | while ($true) 8 | { 9 | $processes = Get-Process | Where-Object {![string]::IsNullOrEmpty($_)} | Group-Object -Property name 10 | 11 | $heavyweights = $processes | Where-Object Count -ge 5 12 | Write-Output $heavyweights.Count 13 | 14 | $middleweights = $processes | Where-Object {$_.Count -ge 2 -and $_.Count -lt 5} 15 | Write-Output $middleweights.Count 16 | 17 | $featherweights = $processes | Where-Object Count -lt 2 18 | Write-Output $featherweights.Count 19 | 20 | Start-Sleep -Seconds 2 21 | } 22 | 23 | # Use Ctrl+B (PowerShell ISE) or F6 (VS Code) to break into a running script at any time -------------------------------------------------------------------------------- /3 - Entering the debugger with Wait-Debugger.ps1: -------------------------------------------------------------------------------- 1 | ################################################ 2 | # 3 | # PSv5: Entering the debugger with Wait-Debugger 4 | # 5 | ################################################ 6 | 7 | $i = 0 8 | while ($true) 9 | { 10 | $i++ 11 | 12 | $processes = Get-Process | Where-Object {![string]::IsNullOrEmpty($_)} | Group-Object -Property name 13 | 14 | $heavyweights = $processes | Where-Object Count -ge 5 15 | Write-Output $heavyweights.Count 16 | 17 | if ($i -ge 5) { 18 | Wait-Debugger 19 | } 20 | 21 | $middleweights = $processes | Where-Object {$_.Count -ge 2 -and $_.Count -lt 5} 22 | Write-Output $middleweights.Count 23 | 24 | $featherweights = $processes | Where-Object Count -lt 2 25 | Write-Output $featherweights.Count 26 | 27 | Start-Sleep -Seconds 1 28 | } -------------------------------------------------------------------------------- /4 - Debugging with DebugPx.ps1: -------------------------------------------------------------------------------- 1 | ############################### 2 | # 3 | # PSv3+: Debugging with DebugPx 4 | # 5 | ############################### 6 | 7 | $i = 0 8 | 9 | while ($true) 10 | { 11 | $processes = Get-Process | Where-Object {![string]::IsNullOrEmpty($_)} | Group-Object -Property name 12 | 13 | $heavyweights = $processes | Where-Object Count -ge 5 14 | Write-Output $heavyweights.Count 15 | 16 | breakpoint # This comes from DebugPx 17 | 18 | $middleweights = $processes | Where-Object {$_.Count -ge 2 -and $_.Count -lt 5} 19 | Write-Output $middleweights.Count 20 | 21 | $featherweights = $processes | Where-Object Count -lt 2 22 | Write-Output $featherweights.Count 23 | 24 | $i++ 25 | 26 | Start-Sleep -Seconds 2 27 | } -------------------------------------------------------------------------------- /5 - More Debugging with DebugPx.ps1: -------------------------------------------------------------------------------- 1 | #################################### 2 | # 3 | # PSv3+: More Debugging with DebugPx 4 | # 5 | #################################### 6 | 7 | function Debug-This { 8 | [CmdletBinding()] 9 | param() 10 | 11 | $i = 0 12 | 13 | while ($true) 14 | { 15 | $processes = Get-Process | Where-Object {![string]::IsNullOrEmpty($_)} | Group-Object -Property name 16 | 17 | $heavyweights = $processes | Where-Object Count -ge 5 18 | Write-Output $heavyweights.Count 19 | 20 | ifdebug { 21 | $debugInfo = $heavyweights.Group | Format-List * | Out-String 22 | $debugInfo -replace '^\s+|\s+$' -split "`n" | Write-Debug 23 | } 24 | 25 | breakpoint {$i -ge 1} 26 | 27 | $middleweights = $processes | Where-Object {$_.Count -ge 2 -and $_.Count -lt 5} 28 | Write-Output $middleweights.Count 29 | 30 | $featherweights = $processes | Where-Object Count -lt 2 31 | Write-Output $featherweights.Count 32 | 33 | $i++ 34 | 35 | Start-Sleep -Seconds 2 36 | } 37 | } 38 | 39 | # The -Debug parameter normally leaves a lot to be desired. 40 | # DebugPx fixes this. 41 | # It also works better in PowerShell 7 and later. 42 | Debug-This -Debug -------------------------------------------------------------------------------- /6 - Advanced Debugging with DebugPx.ps1: -------------------------------------------------------------------------------- 1 | ######################################## 2 | # 3 | # PSv3+: Advanced Debugging with DebugPx 4 | # 5 | ######################################## 6 | 7 | # Create a test module 8 | New-Module -Name DebugTest { 9 | Export-ModuleMember 10 | 11 | $hiddenSecretCounter = 0 12 | 13 | function Set-InternalStuff { 14 | [CmdletBinding()] 15 | [System.Diagnostics.DebuggerHidden()] 16 | param( 17 | [Parameter(Position=0, Mandatory=$true)] 18 | [ValidateNotNullOrEmpty()] 19 | [string] 20 | $Value 21 | ) 22 | $script:hiddenSecretCounter++ 23 | $internalStuff = $Value 24 | } 25 | 26 | function Invoke-ScriptBlock { 27 | [CmdletBinding()] 28 | [System.Diagnostics.DebuggerStepThrough()] 29 | param( 30 | [Parameter(Position=0, Mandatory=$true)] 31 | [ValidateNotNull()] 32 | [ScriptBlock] 33 | $ScriptBlock 34 | ) 35 | Set-InternalStuff 'It is easy to really confuse users of your functions.' 36 | Set-InternalStuff 'Especially if their breakpoints trip on your internals.' 37 | 38 | & $ScriptBlock 39 | 40 | Set-InternalStuff 'Just say no. Make debugging easier for your users.' 41 | } 42 | Export-ModuleMember -Function Invoke-ScriptBlock 43 | } | Import-Module 44 | 45 | # Look at the exports 46 | Get-Command -Module DebugTest 47 | 48 | # Note that there is no hiddenSecretCounter variable here, but there was one 49 | # in the module, and it was already incremented 50 | Get-Variable -Name hiddenSecretCounter 51 | 52 | # Imagine you wanted to peek inside your module and look around in that scope 53 | # to check the state of variables in the module from the debugger 54 | Debug-Module -Name DebugTest 55 | 56 | # Does the variable exist in this scope? 57 | $hiddenSecretCounter 58 | 59 | # And to confirm we're in the right scope 60 | Get-Variable -Name hiddenSecretCounter -Scope 0 61 | 62 | # Now let's detach our debugger 63 | d 64 | 65 | # How do you help your end users do easier debugging of *their* code? 66 | # By hiding the internals from the debugger. 67 | Set-PSBreakpoint -Command Set-InternalStuff 68 | Invoke-ScriptBlock { 69 | 'Inside my script block' 70 | } 71 | 72 | # How about debugging inside of *your* script block? 73 | Invoke-ScriptBlock { 74 | 'I can debug this' 75 | breakpoint 76 | } 77 | 78 | # Then detach 79 | d 80 | 81 | # And remove the test module and cleanup 82 | Remove-Module -Name DebugTest 83 | Remove-Module -Name DebugPx 84 | Get-PSBreakpoint | Remove-PSBreakpoint -------------------------------------------------------------------------------- /7 - Editing and debugging jobs.ps1: -------------------------------------------------------------------------------- 1 | ################################## 2 | # 3 | # PSv5: Editing and debugging jobs 4 | # 5 | ################################## 6 | 7 | # If you try this yourself, you will need to change this path 8 | $sandbox = Join-Path -Path $env:USERPROFILE -ChildPath 'OneDrive - Kamtanix, Ltd\Consulting\Presentations\TechMentor Live! 360 Orlando 2019\TMW06 - Become a PowerShell Debugging Ninja!' 9 | 10 | # Let's get a few jobs running 11 | $fileOne = Get-Command -Name "${sandbox}/2 - Entering the debugger without breakpoints.ps1" 12 | $fileTwo = Get-Command -Name "${sandbox}/3 - Entering the debugger with Wait-Debugger.ps1" 13 | $jobs = @() 14 | $jobs += Start-Job -ScriptBlock $fileOne.ScriptBlock 15 | $jobs += Start-Job -ScriptBlock $fileTwo.ScriptBlock 16 | 17 | # Now let's have a look at the currently running jobs (one of them 18 | # will eventually hit a breakpoint) 19 | $jobs 20 | 21 | # Debugging a job is easy with Debug-Job 22 | Debug-Job -Job $jobs[0] 23 | 24 | # Notice the (d) detach command in the debugger commands 25 | 26 | # From the debugger, use d to detach and let the job continue, 27 | # or q to quit the debugger and stop the job in its tracks 28 | 29 | # Notice where the debugger starts when you enter one that internally 30 | # used Wait-Debugger 31 | Debug-Job -Job $jobs[1] 32 | 33 | # Detach from the job to let it continue 34 | 35 | # Now let's clean up our jobs 36 | $jobs | Stop-Job -PassThru | Remove-Job 37 | Remove-Variable -Name jobs -------------------------------------------------------------------------------- /8 - Attaching to a remote PowerShell host and debugging runspaces.ps1: -------------------------------------------------------------------------------- 1 | ##################################################################### 2 | # 3 | # PSv5: Attaching to a remote PowerShell host and debugging runspaces 4 | # 5 | ##################################################################### 6 | 7 | # If this isn't Windows PowerShell or PowerShell Core on Windows, it won't work 8 | # because Enter-PSHostProcess is not supported in that version of PowerShell 9 | if ($PSVersionTable.PSVersion -ge '6.0' -and $PSVersionTable.Platform -eq 'Unix') { 10 | Write-Warning 'This script uses Enter-PSHostProcess which only works on Windows PowerShell or PowerShell Core on Windows.' 11 | return 12 | } 13 | 14 | # If you try this yourself, you will need to change this path 15 | $sandbox = Join-Path -Path $env:USERPROFILE -ChildPath 'OneDrive - Kamtanix, Ltd\Consulting\Presentations\TechMentor Live! 360 Orlando 2019\TMW06 - Become a PowerShell Debugging Ninja!' 16 | 17 | # Let's fire up a few remote processes that have PowerShell hosts 18 | Start-Process -FilePath 'powershell.exe' -WorkingDirectory $sandbox -WindowStyle Minimized -ArgumentList @( 19 | "-NoLogo","-NoProfile","-NoExit","-Command",".","'${sandbox}\2 - Entering the debugger without breakpoints.ps1'" 20 | ) 21 | while (-not ($process = Get-Process -Name powershell -ErrorAction Ignore | Where-Object Id -ne $pid)) { 22 | Start-Sleep -Milliseconds 250 23 | } 24 | $process 25 | 26 | # We can enter the remote process using Enter-PSHostProcess 27 | Enter-PSHostProcess -Process $process 28 | 29 | # Have a look at what's running in the remote process 30 | Get-Runspace 31 | 32 | # RemoteHost is the runspace created when we entered the process. 33 | # Other runspaces are the runspaces that process was running before 34 | # we entered the process. 35 | 36 | # Let's debug the runspace where our script is running 37 | Debug-Runspace -Name Runspace1 38 | 39 | # See how even the file opened in ISE? Now all of the debugging 40 | # skills we've been building up apply, so we can step, look at 41 | # variables, etc. 42 | 43 | # Let's just detach and let the runspace continue to execute 44 | d 45 | 46 | # And when we exit the remote process, the remote files close 47 | Exit-PSHostProcess 48 | 49 | # Now we can stop our process 50 | Stop-Process -InputObject $process -------------------------------------------------------------------------------- /Abstract.md: -------------------------------------------------------------------------------- 1 | # Title 2 | 3 | Become a PowerShell Debugging Ninja 4 | 5 | # Level 6 | 7 | 301 - Masters 8 | 9 | # Session Type 10 | 11 | General 12 | 13 | # Abstract 14 | 15 | You've written PowerShell scripts or functions, and maybe packaged them up in a module. Then suddenly, when you least expect it, it shows up. It's red, and it's scary. You've hit a bug. But fear not! You, too, can become a PowerShell Debugging Ninja! Come to this session to learn how! Hi-yaaaaaaaah! 16 | 17 | # Learning Objectives 18 | 19 | You will learn: 20 | 21 | 1. "Soft" debugging skills that reduce or eliminate the need to work with a PowerShell debugger when it's not necessary. 22 | 1. "Hard" debugging skills that will help you get the most value for the least effort when working with the PowerShell debugger. 23 | 1. Best practices and tips and tricks that increase reliability and efficiency when writing and debugging PowerShell scripts and modules. 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Debugging PowerShell 2 | 3 | This repository contains sample scripts used to demonstrate debugging PowerShell with PowerShell Core running in Visual Studio Code on macOS and with Windows PowerShell running in Windows PowerShell ISE on Windows. 4 | 5 | This session was delivered at the 2018 PowerShell and DevOps Summit in Bellevue WA. 6 | -------------------------------------------------------------------------------- /TMW06 - Become a PowerShell Debugging Ninja!.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KirkMunro/debugging-powershell-session/f437eecb4d6125a7023789a041fb3a5b9644f028/TMW06 - Become a PowerShell Debugging Ninja!.pptx --------------------------------------------------------------------------------