filmov
tv
PowerShell 22 Dot Sourcing and using a Try Catch loop to find and correct script-breaking errors
Показать описание
In this video, the Kilt Guy uses Dot Sourcing to load a new function (with parameters) and adds it to a Try/Catch loop to do some error checking inside of a different function.
Commands discussed:
Get-LocalUser
New-LocalUser
Get-Command
Remove-LocalUser
0:00 Intro
0:29 Describing a scenario where a new user might need to be created on the fly
1:01 Introducing the Try/Catch loop
1:19 Designing a new function to add a new user (Add-NewUser) which requires a parameter
4:12 Adding the Add-NewUser function to the shell with Dot Sourcing
5:17 Validating the Dot Sourcing worked by checking for the function in the Get-Command results
6:42 Testing the Add-NewUser function
7:20 Validating the outcome of Add-NewUser
7:37 Removing the testuser account with Remove-LocalUse
7:55 Introducing the Try/Catch loop
9:23 Demonstrating how to (deliberately) create an error that can be caught by the loop
10:32 Showing the difference between Write-Warning and Write-Host in our script
11:33 Testing our Try/Catch loop with both valid and invalid information
13:14 Where to place the Try/Catch loop in our script
15:01 Outro
Commands discussed:
Get-LocalUser
New-LocalUser
Get-Command
Remove-LocalUser
0:00 Intro
0:29 Describing a scenario where a new user might need to be created on the fly
1:01 Introducing the Try/Catch loop
1:19 Designing a new function to add a new user (Add-NewUser) which requires a parameter
4:12 Adding the Add-NewUser function to the shell with Dot Sourcing
5:17 Validating the Dot Sourcing worked by checking for the function in the Get-Command results
6:42 Testing the Add-NewUser function
7:20 Validating the outcome of Add-NewUser
7:37 Removing the testuser account with Remove-LocalUse
7:55 Introducing the Try/Catch loop
9:23 Demonstrating how to (deliberately) create an error that can be caught by the loop
10:32 Showing the difference between Write-Warning and Write-Host in our script
11:33 Testing our Try/Catch loop with both valid and invalid information
13:14 Where to place the Try/Catch loop in our script
15:01 Outro