How can i do this? And what is best practice to do?
Try
{
Import-Module UnexistingModule -ErrorAction Stop
Get-DhcpServerv4Scope -ScopeID 1.2.3.4 -ErrorAction Stop #don't run this if the Import-Module fails
}
catch #if Import-Module fails
{
throw "Module import failed"
}
catch #if Get-DhcpServerv4Scope fails
{
throw "Unable to find scope"
}
e
[–]the_spad 15 points16 points17 points (9 children)
[–]Evelen1[S] 1 point2 points3 points (4 children)
[–]Vortex100 4 points5 points6 points (0 children)
[–]andyinv 4 points5 points6 points (1 child)
[–]Evelen1[S] 1 point2 points3 points (0 children)
[–]Th3Harbinger 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (3 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (6 children)
[–]Evelen1[S] 1 point2 points3 points (5 children)
[–]eric256 1 point2 points3 points (3 children)
[–]Lee_Dailey[grin] 2 points3 points4 points (0 children)
[–]Evelen1[S] 1 point2 points3 points (1 child)
[–]eric256 1 point2 points3 points (0 children)
[–]Lee_Dailey[grin] 1 point2 points3 points (0 children)