Private/Test-OriAzExrIsInExceptionList.ps1
<#
.DESCRIPTION It get values of item in laguage based on LanguageMask variable .SYNOPSIS It setup on non-live environemts sending SMS to fake .PARAMETER ListedExceptions List of execptions where is the reason to retry .PARAMETER ExceptionMessage Execetion message to evaluate .EXAMPLE Test-OriAzExrIsInExceptionList ` -ListedExceptions @("Timeout", "Try again later") ` -ExceptionMessage 'Something TimeOut Something' #> function Test-OriAzExrIsInExceptionList { [OutputType('Boolean')] [CmdletBinding()] param( [Parameter(Mandatory = $true, HelpMessage = "List of exptions")] [string[]] $ListedExceptions, [Parameter(Mandatory = $true, HelpMessage = "Exception message")] [string] $ExceptionMessage ) #in case of any error we want to stop execution, in stderr having the error. Use try-catch to handle errors if needed. $ErrorActionPreference = "Stop"; Write-Debug "-- Test-OriAzExrIsInExceptionList --" foreach ($OneItem in $ListedExceptions) { Write-Debug "OneItem: $OneItem " } Write-Debug "ExceptionMessage: $ExceptionMessage " foreach ($OneItem in $ListedExceptions) { if ($ExceptionMessage -ilike "*$OneItem*") { return $true } } return $false } |