Skip to content

Commit 0ab82b1

Browse files
committed
Fixes for collecting information from SQL Express instances
1 parent c67ff5b commit 0ab82b1

1 file changed

Lines changed: 28 additions & 12 deletions

File tree

Modules/SqlServerDatabaseEngineInformation/SqlServerDatabaseEngineInformation.psm1

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7871,7 +7871,7 @@ function Get-ResourceGovernorInformation {
78717871
ClassifierFunction = $Server.ResourceGovernor.ClassifierFunction
78727872
ReconfigurePending = $Server.ResourceGovernor.ReconfigurePending
78737873
ResourcePools = @() + (
7874-
$Server.ResourceGovernor.ResourcePools | ForEach-Object {
7874+
$Server.ResourceGovernor.ResourcePools | Where-Object { $_.ID } | ForEach-Object {
78757875
New-Object -TypeName psobject -Property @{
78767876
ID = $_.ID # System.Int32 ID {get;}
78777877
IsSystemObject = $_.IsSystemObject # System.Boolean IsSystemObject {get;}
@@ -7886,11 +7886,11 @@ function Get-ResourceGovernorInformation {
78867886
#Urn = $_.Urn # Microsoft.SqlServer.Management.Sdk.Sfc.Urn Urn {get;}
78877887
#UserData = $_.UserData # System.Object UserData {get;set;}
78887888
WorkloadGroups = @() + (
7889-
$_.WorkloadGroups | ForEach-Object {
7889+
$_.WorkloadGroups | Where-Object { $_.ID } | ForEach-Object {
78907890
New-Object -TypeName psobject -Property @{
78917891
GroupMaximumRequests = $_.GroupMaximumRequests # System.Int32 GroupMaximumRequests {get;set;}
78927892
ID = $_.ID # System.Int32 ID {get;}
7893-
Importance = $_.Importance.ToString() # Microsoft.SqlServer.Management.Smo.WorkloadGroupImportance Importance {get;set;}
7893+
Importance = if ($_.Importance) { $_.Importance.ToString() } else { $null } # Microsoft.SqlServer.Management.Smo.WorkloadGroupImportance Importance {get;set;}
78947894
IsSystemObject = $_.IsSystemObject # System.Boolean IsSystemObject {get;}
78957895
MaximumDegreeOfParallelism = $_.MaximumDegreeOfParallelism # System.Int32 MaximumDegreeOfParallelism {get;set;}
78967896
Name = $_.Name # System.String Name {get;set;}
@@ -10992,14 +10992,27 @@ function Get-DatabaseMailInformation {
1099210992

1099310993
# For some reason SMO exposes these as name\value pairs instead of as properties
1099410994
# As of SQL 2012 there's no mechanism to add new configuration values so I decided to go ahead and transform them here
10995-
ConfigurationValues = New-Object -TypeName psobject -Property @{
10996-
AccountRetryAttempts = $Server.Mail.ConfigurationValues['AccountRetryAttempts'].Value # System.String Value {get;set;}
10997-
AccountRetryDelaySeconds = $Server.Mail.ConfigurationValues['AccountRetryDelay'].Value # System.String Value {get;set;}
10998-
DatabaseMailExeMinimumLifeTimeSeconds = $Server.Mail.ConfigurationValues['DatabaseMailExeMinimumLifeTime'].Value # System.String Value {get;set;}
10999-
DefaultAttachmentEncoding = $Server.Mail.ConfigurationValues['DefaultAttachmentEncoding'].Value # System.String Value {get;set;}
11000-
LoggingLevel = $Server.Mail.ConfigurationValues['LoggingLevel'].Value # System.String Value {get;set;}
11001-
MaxFileSizeBytes = $Server.Mail.ConfigurationValues['MaxFileSize'].Value # System.String Value {get;set;}
11002-
ProhibitedExtensions = $Server.Mail.ConfigurationValues['ProhibitedExtensions'].Value # System.String Value {get;set;}
10995+
# Return NULLs if server is Express edition
10996+
ConfigurationValues = if ($Server.Information.Edition -inotlike 'Express*') {
10997+
New-Object -TypeName psobject -Property @{
10998+
AccountRetryAttempts = $Server.Mail.ConfigurationValues['AccountRetryAttempts'].Value # System.String Value {get;set;}
10999+
AccountRetryDelaySeconds = $Server.Mail.ConfigurationValues['AccountRetryDelay'].Value # System.String Value {get;set;}
11000+
DatabaseMailExeMinimumLifeTimeSeconds = $Server.Mail.ConfigurationValues['DatabaseMailExeMinimumLifeTime'].Value # System.String Value {get;set;}
11001+
DefaultAttachmentEncoding = $Server.Mail.ConfigurationValues['DefaultAttachmentEncoding'].Value # System.String Value {get;set;}
11002+
LoggingLevel = $Server.Mail.ConfigurationValues['LoggingLevel'].Value # System.String Value {get;set;}
11003+
MaxFileSizeBytes = $Server.Mail.ConfigurationValues['MaxFileSize'].Value # System.String Value {get;set;}
11004+
ProhibitedExtensions = $Server.Mail.ConfigurationValues['ProhibitedExtensions'].Value # System.String Value {get;set;}
11005+
}
11006+
} else {
11007+
New-Object -TypeName psobject -Property @{
11008+
AccountRetryAttempts = $null
11009+
AccountRetryDelaySeconds = $null
11010+
DatabaseMailExeMinimumLifeTimeSeconds = $null
11011+
DefaultAttachmentEncoding = $null
11012+
LoggingLevel = $null
11013+
MaxFileSizeBytes = $null
11014+
ProhibitedExtensions = $null
11015+
}
1100311016
}
1100411017

1100511018
# $Server.Mail.ConfigurationValues | ForEach-Object {
@@ -11611,7 +11624,10 @@ function Get-SqlServerDatabaseEngineInformation {
1161111624
# AGENT
1161211625
######################
1161311626

11614-
if ($ServerInformation.Server.Configuration.General.ServerType -ieq 'standalone') {
11627+
if (
11628+
$ServerInformation.Server.Configuration.General.ServerType -ieq 'standalone' -and
11629+
$Server.Information.Edition -inotlike 'Express*'
11630+
) {
1161511631

1161611632
# Service
1161711633
######################

0 commit comments

Comments
 (0)