Introducing
IntroducingWindowsServer2016_ebook
IntroducingWindowsServer2016_ebook
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Figure 5-1: Sample code in the Windows Powershell ISE with remote debugging<br />
When a script encounters a breakpoint in a remote session, it will display a message indicating it has<br />
done so. Figure 5-2 illustrates a sample message.<br />
Figure 5-2: Breakpoint warning in a remote session<br />
Not all remote sessions will support a remote debug session, but when you connect to the remote<br />
session using the Connect-PSSession cmdlet, you will see the output shown in Figure 5-3. The output<br />
also lets you know whether it is available.<br />
Figure 5-3: Remote debug availability<br />
If remote debug is available, you can connect to the session by using the Enter-PSSession cmdlet,<br />
which connects you directly to the debugger<br />
Figure 5-4: Remote debugger in action<br />
Job debugging<br />
One useful function in Windows PowerShell is the ability to execute scripts as background jobs. These<br />
jobs can run without clogging up the main console screen, letting you proceed with additional tasks.<br />
This was fine, but these jobs could sometimes be difficult to troubleshoot and could require a lot of<br />
trial and error in order to develop robust scripts that could truly be run as jobs.<br />
Now, with Server 2016, Windows PowerShell introduces the Debug-Job cmdlet, which gives you the<br />
ability to debug these background jobs more effectively. Figure 5-5 shows this cmdlet being used.<br />
Note how Debug-Job shows you the line and character at which the job broke.<br />
139 CHAPTER 5 | Systems management