Cannot bind argument to parameter because it is an empty string

I am trying to monitor certain production URLs based on which certain jobs are triggered. I was trying to work on a script that monitors the URLs, create tickets in ServiceNow & send out an email for the URLs that have failed along with the IncidentIDs created along with a HTML Table of the URLs that failed along with the Response Times and Error Status

I have a function that Creates ServiceNow Tickets, and Sending mails.

Function SplitTicketData()
{
    [CmdletBinding()]
    param(
            [Parameter(Position=0,mandatory=$true)]  [string[]] $SNOWIncidentIDs,
            [Parameter(Position=1,mandatory=$true)]  [string[]] $SNOWSysIDs
         )
        
        Write-IntoLog "********************************SPLIT FUNCTION STARTS HERE*********************************"
        Write-IntoLog "Entered into Split Function to Split the Incident and System IDs to generate Data"
        Write-IntoLog $SNOWIncidentIDs,
        Write-IntoLog $SNOWSysIDs
        Write-IntoLog "********************************SPLIT FUNCTION ENDS HERE***********************************"

        #SPLIT Incident IDs
        $Incidents = $SNOWIncidentIDs -split '~'
        $SystemIDs = $SNOWSysIDs -split '~'
       
        $CountofIncidents=0
        $CountofIncidents = $Incidents.length+1
 
        $iLoopCount = 0
        $global:oTicketData = foreach($Inc in $Incidents)
        {
        "The Incident ID is $($Incidents[$iLoopCount])  The URL is - https://devinstance###.service-now.com/task.do?sys_id=$($SystemIDs[$iLoopCount])"
        $iLoopCount++
        }
        
        Write-IntoLog " The Ticket Data is `n $global:oTicketData"
        return $global:oTicketData
}
## The URI list to test
$URLListFile = $DefaultPath + $URLList
$ListOfURLs = Get-Content $URLListFile -ErrorAction SilentlyContinue
  $Result = @()

  Foreach($Uri in $ListOfURLs) 
  {
    $time = try{
    $request = $null
    ## Request the URI, and measure how long the response took.
    $result1 = Measure-Command { $request = Invoke-WebRequest -Uri $uri }
    $result1.TotalMilliseconds
  } 
  catch
  {

    $request = $_.Exception.Response
    $time = -1
  }  
    $result += [PSCustomObject] @{
    Time = Get-Date;
    Uri = $uri;
    StatusCode = [int] $request.StatusCode;
    StatusDescription = $request.StatusDescription;
    ResponseLength = $request.RawContentLength;
    TimeTaken =  $time; 
  }

}

#Prepare email body in HTML format
$HTMLHeader = "Website Availability ReportWebsite Availability Report 
if($result -ne $null)
{
    $Outputreport = $HTMLHeader+$TableDetails
    #$Outputreport = "Website Availability Report
    Foreach($Entry in $Result)
    {
        if($Entry.StatusCode -ne "200")
        {
            $Outputreport += ""
            $Description = "We are facing issues with accessing the portal $($Entry.uri). 
                            and Access to the same is restricted due to the Error Status of $($Entry.StatusDescription)"
            
            Write-IntoLog $Description
            
            $ResponseData = Create-SNOWTicket `
                                -Assignedto "ATF User" `
                                -ShortDescription "Issues with Accessing Web URL" `
                                -Description $Description `
                                -Urgency 1 `
                                -Impact 2 `
                                -Category "Network" `
                                -SecurePasswordData $SecurePasswordDataFilePath `
                                -AssignmentGroup "Network" `
                                -Subcategory "Internal Application" `
                                -State "New"
            
             #DECLARING GLOBAL VARIABLES for INCIDENT_ID and SYSTEM ID
             $global:Incident_ID = $($ResponseData.result.number)
			 $global:System_ID = $($ResponseData.result.sys_id)
        }
        else
        {
            $Outputreport += ""
        }
        $Outputreport += "$($Entry.uri)
                          $($Entry.StatusCode)
                          $($Entry.StatusDescription)
                          $($Entry.ResponseLength)
                          $($Entry.timetaken)"
        
        $IncidentIDs += $global:Incident_ID + "~" 
        $SystemIDs += $global:System_ID + "~" 

        $global:IncidentIDSplit = ($global:IncidentIDs.Split("~",3)) -replace ".$".Trim()
        $global:SysIDSplit = ($global:SystemIDs.Split("~",3)) -replace ".$".Trim()
    }
    $Outputreport += ""
}
$Outputreport | out-file $HtmFilePathOutput

Write-IntoLog " Outside Loop Incident IDs - $IncidentIDSplit " 

#IncidentID goes into the log file without issues however raises issues when passing data to a function SplitTicketData below<
Write-IntoLog " Outside Loop System IDs - $SysIDSplit"

#SysIDgoes into the log file without issues however raises issues when pasisng data to a function SplitTicketData below

#Function To Call code for Splitting and Generating a STRING for e-mails
SplitTicketData -SNOWIncidentIDs $IncidentIDSplit `
                -SNOWSysIDs $SysIDSplit
Error: - SplitTicketData : Cannot bind argument to parameter 'SNOWIncidentIDs' because it is an empty string. At D:\01_PowerShell\WebMonitoring\14Jan2017 - URLMonitoringServiceNow WIP.ps1:340 char:34 + SplitTicketData -SNOWIncidentIDs $IncidentIDSplit ` + ~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [SplitTicketData], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,SplitTicketData

I am trying to monitor certain production URLs based on which certain jobs are triggered. I was trying to work on a script that monitors the URLs, create tickets in ServiceNow & send out an email for the URLs that have failed along with the IncidentIDs created along with a HTML Table of the URLs that failed along with the Response Times and Error Status

I have a function that Creates ServiceNow Tickets, and Sending mails.

Function SplitTicketData()
{
    [CmdletBinding()]
    param(
            [Parameter(Position=0,mandatory=$true)]  [string[]] $SNOWIncidentIDs,
            [Parameter(Position=1,mandatory=$true)]  [string[]] $SNOWSysIDs
         )
        
        Write-IntoLog "********************************SPLIT FUNCTION STARTS HERE*********************************"
        Write-IntoLog "Entered into Split Function to Split the Incident and System IDs to generate Data"
        Write-IntoLog $SNOWIncidentIDs,
        Write-IntoLog $SNOWSysIDs
        Write-IntoLog "********************************SPLIT FUNCTION ENDS HERE***********************************"

        #SPLIT Incident IDs
        $Incidents = $SNOWIncidentIDs -split '~'
        $SystemIDs = $SNOWSysIDs -split '~'
       
        $CountofIncidents=0
        $CountofIncidents = $Incidents.length+1
 
        $iLoopCount = 0
        $global:oTicketData = foreach($Inc in $Incidents)
        {
        "The Incident ID is $($Incidents[$iLoopCount])  The URL is - https://devinstance###.service-now.com/task.do?sys_id=$($SystemIDs[$iLoopCount])"
        $iLoopCount++
        }
        
        Write-IntoLog " The Ticket Data is `n $global:oTicketData"
        return $global:oTicketData
}
## The URI list to test
$URLListFile = $DefaultPath + $URLList
$ListOfURLs = Get-Content $URLListFile -ErrorAction SilentlyContinue
  $Result = @()

  Foreach($Uri in $ListOfURLs) 
  {
    $time = try{
    $request = $null
    ## Request the URI, and measure how long the response took.
    $result1 = Measure-Command { $request = Invoke-WebRequest -Uri $uri }
    $result1.TotalMilliseconds
  } 
  catch
  {

    $request = $_.Exception.Response
    $time = -1
  }  
    $result += [PSCustomObject] @{
    Time = Get-Date;
    Uri = $uri;
    StatusCode = [int] $request.StatusCode;
    StatusDescription = $request.StatusDescription;
    ResponseLength = $request.RawContentLength;
    TimeTaken =  $time; 
  }

}

#Prepare email body in HTML format
$HTMLHeader = "Website Availability Report"
if($result -ne $null)
{
    $Outputreport = $HTMLHeader+$TableDetails
    #$Outputreport = "~URL~StatusCode~Status Description~ResponseLength~Time Taken"
    Foreach($Entry in $Result)
    {
        if($Entry.StatusCode -ne "200")
        {
            $Outputreport += ""
            $Description = "We are facing issues with accessing the portal $($Entry.uri). 
                            and Access to the same is restricted due to the Error Status of $($Entry.StatusDescription)"
            
            Write-IntoLog $Description
            
            $ResponseData = Create-SNOWTicket `
                                -Assignedto "ATF User" `
                                -ShortDescription "Issues with Accessing Web URL" `
                                -Description $Description `
                                -Urgency 1 `
                                -Impact 2 `
                                -Category "Network" `
                                -SecurePasswordData $SecurePasswordDataFilePath `
                                -AssignmentGroup "Network" `
                                -Subcategory "Internal Application" `
                                -State "New"
            
             #DECLARING GLOBAL VARIABLES for INCIDENT_ID and SYSTEM ID
             $global:Incident_ID = $($ResponseData.result.number)
			 $global:System_ID = $($ResponseData.result.sys_id)
        }
        else
        {
            $Outputreport += ""
        }
        $Outputreport += "$($Entry.uri)
                          $($Entry.StatusCode)
                          $($Entry.StatusDescription)
                          $($Entry.ResponseLength)
                          $($Entry.timetaken)"
        
        $IncidentIDs += $global:Incident_ID + "~" 
        $SystemIDs += $global:System_ID + "~" 

        $global:IncidentIDSplit = ($global:IncidentIDs.Split("~",3)) -replace ".$".Trim()
        $global:SysIDSplit = ($global:SystemIDs.Split("~",3)) -replace ".$".Trim()
    }
    $Outputreport += ""
}
$Outputreport | out-file $HtmFilePathOutput

Write-IntoLog "Outside Loop Incident IDs: $IncidentIDSplit" 
#IncidentID goes into the log file without issues however raises issues when passing data to a function SplitTicketData below
Write-IntoLog "Outside Loop System IDs: $SysIDSplit"
#SysIDgoes into the log file without issues however raises issues when pasisng data to a function SplitTicketData below

SplitTicketData -SNOWIncidentIDs $IncidentIDSplit `
                -SNOWSysIDs $SysIDSplit
Error: - SplitTicketData : Cannot bind argument to parameter 'SNOWIncidentIDs' because it is an empty string. At D:\01_PowerShell\WebMonitoring\14Jan2017 - URLMonitoringServiceNow WIP.ps1:340 char:34 + SplitTicketData -SNOWIncidentIDs $IncidentIDSplit ` + ~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [SplitTicketData], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,SplitTicketData

FYI — You’ll need to delete one of your post as you duplicated the first.

As, you really don’t state your question, but just show the error. Your first step is to break this into pieces and make sure you are getting back what you’d expect at each segment.

For example, in your post, if you open in the PowerShell ISE, you’ll immediately see you have code / syntax errors indicated by the red squiggly line. For example …

        Write-IntoLog "********************************SPLIT FUNCTION STARTS HERE*********************************"
        Write-IntoLog "Entered into Split Function to Split the Incident and System IDs to generate Data"
        Write-IntoLog $SNOWIncidentIDs,
        Write-IntoLog $SNOWSysIDs
        Write-IntoLog "********************************SPLIT FUNCTION ENDS HERE***********************************"

and here …

        #$Outputreport = "Website Availability Report

Of course, I have never used ServiceNow, and obviously don’t have access to it.
So, again, test this function, one segment at a time (comment out blocks and run) to make sure things are correct.

remove the comma at the end of line 11

        Write-IntoLog $SNOWIncidentIDs,