What is the maximum number of arguments a Powershell V2.0 script will accept when invoked from the command line or a batch file?
What is the maximum number of arguments a Powershell V2.0 script will accept when
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The theoretical max would be 2 GB worth of arguments. 🙂 That comes from the fact that unmapped args in a function map to an Object array (
$args) and arrays in .NET 2.0/4.0 (with 4.5 installed) can be indexed up to Int32.MaxValue. From what I understand the actual limit is somewhat lower than that depending on the actual type. FWIW I can create an array of object 128MB in size in PowerShell. I think the more realistic limit to the number of arguments are limitations on the command line length. At one point in time cmd.exe had a max line length of 8191. I’m not sure what PowerShell’s max is but I would guess it would be similar to cmd.exe’s max. Also, if an external process needs to be started then these shells go through the CreateProcess API it has a limit of 32,767 characters for the command line passed to the process.