Cannot index into a null array
Hello les experts,
Mon code fonctionne bien mais il affiche l'erreur suivante dans mon retour de script :
Code:
1 2 3 4 5
| Cannot index into a null array.
At xxx.ps1:81 char:34
+ $SqlInstance += ,@($SqlInfo[$i][ <<<< 0])
+ CategoryInfo : InvalidOperation: (0:Int32) [], RuntimeException
+ FullyQualifiedErrorId : NullArray |
Voici le code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| $SqlInfo = @()
$inst = (get-itemproperty 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server').InstalledInstances
For ($i=0 ;$i -le $NumInst;$i++)
{
foreach ($i in $inst)
{
$p = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL').$i
$Instance = $i
$Edition= (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$p\Setup").Edition
$Version = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$p\Setup").Version
$SqlInfo += ,@($Instance,$Edition,$Version)
}
}
$NumInfo=$SqlInfo.count
$SqlInstance = @()
For ($i=0 ;$i -le $NumInfo;$i++)
{
$SqlInstance += ,@($SqlInfo[$i][0])
} |
Merci d'avance pour votre aide.