Search code examples
powershellpowershell-2.0servicenow

PowerShell Error The command line is too long


I am working on PowerShell script that requires me to pass string as param. The string is a comma seperated list of user names. I get the error when i have 100+ user names. But i get no error if the string has less then 100 users. See below. I have tried to pass this value using array with no luck. What is the character limitation for this param and how can i solve this. I am using this in ServiceNow Run PowerShell script. That value of the parameter is passed by ServiceNow using a comma seperated value.

Param(
    [string]$itil_users_a = "A.Syafiq,Aaron.Brown,Aaron.Reynnie,Abd.Jalil,Abdu.Hijazi,Abdul.Onny,Abdullah.Ammar,Abel.Muataco"    
    )

Solution

  • You may be running into the maximum length for command lines - 8191 chars. See this KB article on max command line length.