Created
August 23, 2016 02:04
-
-
Save mattmcnabb/9683a5ca0af21e5415d45d3611e7604b to your computer and use it in GitHub Desktop.
Blog_Removing-Error-entries-in-powershell-functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try | |
{ | |
$Variables = Get-Variable -Scope Global -ErrorAction Stop | |
foreach ($Variable in $Variables) | |
{ | |
$VarName = $Variable.Name | |
$Value = Invoke-Expression "`$$VarName" | |
$TypeName = $Value.PSObject.TypeNames[0] | |
if ($TypeName -eq 'My.Type') {$Value} | |
} | |
} | |
catch [System.Management.Automation.RuntimeException]{$Error.RemoveAt(0)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
catch [System.Management.Automation.RuntimeException]{$Global:Error.RemoveAt(0)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment