How can this powershell code possibly fail with 'Cannot index into a null array.'? It makes no sense to me at all. Surely $cloudPfx should be a non-null array?
$cloudPfx = @( "Foo.pfx", "Bar.pfx", $SSLCertFileName )
$cloudPfx | foreach {
## call some function...
Save-Pfx "Foo\$_" (Join-Path $SomePath "Bar$_")
}
foreach : Cannot index into a null array.
At [that line]
+ $cloudPfx | foreach {
+ ~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [ForEach-Object], RuntimeException
+ FullyQualifiedErrorId : NullArray,Microsoft.PowerShell.Commands.ForEachObjectCommand
$SSLCertFileNameis null. Given that, there must be more to this code than what is posted. What is in$SSLCertFileName, for example?foreachstatements instead of the cmdlet. I.e. change your code toforeach($_ in $cloudPfx) {..}. It will not solve your problem but you will hopefully get a better error message.Save-Pfx "Foo\$_" (Join-Path $SomePath "Bar$_")