-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from PluginsOCSInventory-NG/update_dbinstances
multiple instances retrieval + fix column name displayed as computer
- Loading branch information
Showing
5 changed files
with
74 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,67 @@ | ||
$edition = "Unknown" | ||
$version = "Unknown" | ||
|
||
If (-not (test-path 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server')) | ||
{ | ||
exit | ||
} | ||
|
||
$inst = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server').InstalledInstances | ||
|
||
$xml += "<SOFTWARES>" | ||
$xml += "<PUBLISHER>OCS Inventory Team</PUBLISHER>" | ||
$xml += "<NAME>DBInstances</NAME>" | ||
$xml += "<VERSION>2.0</VERSION>" | ||
$xml += "<COMMENTS>DBInstances plugin</COMMENTS>" | ||
$xml += "</SOFTWARES>" | ||
|
||
foreach ($i in $inst) | ||
{ | ||
$instanceFullName = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL').$i | ||
$instanceName = $instanceFullName | ||
|
||
if($instanceFullName.Contains(".")){ | ||
$instanceSplitted = $instanceFullName.Split(".") | ||
$instanceName = $instanceSplitted.Get(1) | ||
} | ||
|
||
$publisher = "Microsoft Corporation" | ||
$edition = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$instanceFullName\Setup").Edition | ||
$version = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$instanceFullName\Setup").Version | ||
|
||
if($version.StartsWith("10")){ | ||
$serverName = "Microsoft SQL Server 2008" | ||
}elseif($version.StartsWith("10.5")){ | ||
$serverName = "Microsoft SQL Server 2008 R2" | ||
}elseif($version.StartsWith("11")){ | ||
$serverName = "Microsoft SQL Server 2012" | ||
}elseif($version.StartsWith("12")){ | ||
$serverName = "Microsoft SQL Server 2014" | ||
}elseif($version.StartsWith("13")){ | ||
$serverName = "Microsoft SQL Server 2016" | ||
}elseif($version.StartsWith("14")){ | ||
$serverName = "Microsoft SQL Server 2017" | ||
}elseif($version.StartsWith("15")){ | ||
$serverName = "Microsoft SQL Server 2019" | ||
}else{ | ||
$serverName = "Microsoft SQL Server " + $version | ||
} | ||
|
||
$xml += "<DBINSTANCES>" | ||
$xml += "<PUBLISHER>Microsoft Corporation</PUBLISHER>" | ||
$xml += "<NAME>" + $serverName + "</NAME>" | ||
$xml += "<VERSION>" + $version + "</VERSION>" | ||
$xml += "<EDITION>" + $edition + "</EDITION>" | ||
$xml += "<INSTANCE>" + $instanceName + "</INSTANCE>" | ||
$xml += "</DBINSTANCES>" | ||
|
||
$xml += "<SOFTWARES>" | ||
$xml += "<PUBLISHER>Microsoft Corporation</PUBLISHER>" | ||
$xml += "<NAME>" + $serverName + "</NAME>" | ||
$xml += "<VERSION>" + $version + "</VERSION>" | ||
$xml += "<COMMENTS>DBInstances plugin</COMMENTS>" | ||
$xml += "</SOFTWARES>" | ||
|
||
} | ||
|
||
echo $xml | ||
$edition = "Unknown" | ||
$version = "Unknown" | ||
|
||
If (-not (test-path 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server')) | ||
{ | ||
exit | ||
} | ||
|
||
$inst = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL' | Select * | ||
|
||
$xml += "<SOFTWARES>" | ||
$xml += "<PUBLISHER>OCS Inventory Team</PUBLISHER>" | ||
$xml += "<NAME>DBInstances</NAME>" | ||
$xml += "<VERSION>2.0</VERSION>" | ||
$xml += "<COMMENTS>DBInstances plugin</COMMENTS>" | ||
$xml += "</SOFTWARES>" | ||
|
||
$inst.PSObject.Properties | ForEach-Object { | ||
if (-not $_.Name.StartsWith('PS')) { | ||
$instanceFullName = $_.Value | ||
$instanceName = $instanceFullName | ||
if($instanceFullName.Contains(".")){ | ||
$instanceSplitted = $instanceFullName.Split(".") | ||
$instanceName = $instanceSplitted.Get(1) | ||
} | ||
|
||
$publisher = "Microsoft Corporation" | ||
$edition = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$instanceFullName\Setup").Edition | ||
$version = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$instanceFullName\Setup").Version | ||
|
||
if($version.StartsWith("10")){ | ||
$serverName = "Microsoft SQL Server 2008" | ||
}elseif($version.StartsWith("10.5")){ | ||
$serverName = "Microsoft SQL Server 2008 R2" | ||
}elseif($version.StartsWith("11")){ | ||
$serverName = "Microsoft SQL Server 2012" | ||
}elseif($version.StartsWith("12")){ | ||
$serverName = "Microsoft SQL Server 2014" | ||
}elseif($version.StartsWith("13")){ | ||
$serverName = "Microsoft SQL Server 2016" | ||
}elseif($version.StartsWith("14")){ | ||
$serverName = "Microsoft SQL Server 2017" | ||
}elseif($version.StartsWith("15")){ | ||
$serverName = "Microsoft SQL Server 2019" | ||
}else{ | ||
$serverName = "Microsoft SQL Server " + $version | ||
} | ||
|
||
|
||
$xml += "<DBINSTANCES>" | ||
$xml += "<PUBLISHER>Microsoft Corporation</PUBLISHER>" | ||
$xml += "<VERSION_NAME>" + $serverName + "</VERSION_NAME>" | ||
$xml += "<VERSION>" + $version + "</VERSION>" | ||
$xml += "<EDITION>" + $edition + "</EDITION>" | ||
$xml += "<INSTANCE>" + $instanceName + "</INSTANCE>" | ||
$xml += "</DBINSTANCES>" | ||
|
||
$xml += "<SOFTWARES>" | ||
$xml += "<PUBLISHER>Microsoft Corporation</PUBLISHER>" | ||
$xml += "<VERSION_NAME>" + $serverName + "</VERSION_NAME>" | ||
$xml += "<VERSION>" + $version + "</VERSION>" | ||
$xml += "<COMMENTS>DBInstances plugin</COMMENTS>" | ||
$xml += "</SOFTWARES>" | ||
} | ||
} | ||
|
||
echo $xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters