Functions/Find-StringInMSPCompleteTaskInputs.ps1

<#
.SYNOPSIS
    This function returns whether any of the string inputs to the current MSPComplete task contain a
    specified string value.
.DESCRIPTION
 
#>

function Find-StringInMSPCompleteTaskInputs {
    [CmdletBinding(PositionalBinding=$true)]
    [OutputType([Bool])]
    param (
        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [String]$searchString,

        [Parameter(Mandatory=$false)]
        [Switch]$caseSensitive
    )

    # Check if this task is running on the local machine
    if ((Get-BT_RunbookEnvironment).IsRunningOnLocalMachine) {
        return $false
    }

    # Retrieve the MSPComplete input variables
    # Filter out the non-string variables
    # Concatenate all the string values together
    # Search for the string in the combined string
    try {
        if ($caseSensitive) {
            return (((Get-BT_TaskInstance -Ticket $mspc.Ticket -Id $mspc.AutomationInstanceId).InputVariables `
                | ForEach-Object -Process { Invoke-Expression "`$$($_.TaskDataName)" } `
                | Where-Object { $_ -is [String] }) -join '') -cLike "*$($searchString)*"
        }
        else {
            return (((Get-BT_TaskInstance -Ticket $mspc.Ticket -Id $mspc.AutomationInstanceId).InputVariables `
                | ForEach-Object -Process { Invoke-Expression "`$$($_.TaskDataName)" } `
                | Where-Object { $_ -is [String] }) -join '') -like "*$($searchString)*"
        }
    }
    catch {
        return $false
    }
}