Powershell 2.0 Max. Number of arguments

What is the maximum number of arguments that a Powershell V2.0 script will accept when invoked from a command line or batch file?

+4
source share
2 answers

The theoretical maximum will have arguments of 2 GB. :-) This is due to the fact that unmapped args in the function map in the Object array ( $args ) and arrays in .NET 2.0 / 4.0 (with 4.5 installed) can be indexed to Int32 .MaxValue. From what I understand, the actual limit is slightly lower than depending on the actual type. FWIW I can create an array of 128 MB objects in PowerShell. I think a more realistic limit on the number of arguments is to limit the length of the command line. At one point in time, cmd.exe had a maximum line length of 8191 . I'm not sure what PowerShell max is, but I would suggest that it would be similar to cmd.exe max. In addition, if you need to start an external process, then these shells will go through the CreateProcess API, which has a limit of 32,767 characters for the command line passed to the process.

+8
source

I do not know any restrictions, how much do you think to use?

0
source

Source: https://habr.com/ru/post/1436704/


All Articles