Powershell Substring 'Quirk' <p>Seeing 'Exception calling "Substring" with "2" argument(s): "Length cannot be less than zero.' being thrown when running this bit of code inside a script:</p> <pre><code>$PrinterDriverName = $printer.DriverName $PrinterMake = $PrinterDriverName.Substring(0,$PrinterDriverName.IndexOf(" ")) $PrinterModel = $PrinterDriverName.Substring($PrinterDriverName.IndexOf(" ")).Trim() </code></pre> <p>Yet $PrinterMake and $PrinterModel are being populated. What I'm trying fathom out is when these two lines are ran selectively, no errors are returned. Can someone shed some light as to the substring errors are being produced when running this as part of the script please!? Thanks in advance ... Wayne</p>