@@ -119,6 +119,9 @@ Version 2.4.6 12/19/2019
119
119
Added catalog size information.
120
120
Version 2.4.7 01/08/20
121
121
The sync check will now check for multiple status messages to determine if the SUP is still syncing. (Charles - @NoRemoteUsers).
122
+ Version 2.4.8 01/24/20
123
+ Change Get-CatalogInfo function to make its own connection.
124
+ Fix Boolean handling in settings file.
122
125
[TODO] Sync approvals throughout hierarchy.
123
126
[TODO] Orchestrate decline top-down and cleanup bottom-up throughout hierarchy.
124
127
. LINK
@@ -867,14 +870,19 @@ Function Get-CatalogInfo{
867
870
[OutputType ([System.Data.DataTable ])]
868
871
Param (
869
872
[Parameter (Mandatory = $true )]
870
- [System.Data.SqlClient.SqlConnection ] $SqlConnection ,
871
- [Parameter (Mandatory = $true )]
872
- [string ] $SUSDbName ,
873
+ [Microsoft.UpdateServices.Administration.IDatabaseConfiguration ] $WSUSServerDB ,
873
874
[string ] $LogFile = " Get-CatalogInfo.log"
874
875
)
875
876
876
- $query = "
877
- Use $SUSDbName ;
877
+ $SqlConnection = Connect-WSUSDB $WSUSServerDB $LogFile
878
+
879
+ If (! $SqlConnection )
880
+ {
881
+ Add-TextToCMLog $LogFile " Failed to connect to the WSUS database '$ ( $WSUSServerDB.ServerName ) '." $component 1
882
+ }
883
+ else {
884
+ $query =
885
+ " Use $ ( $WSUSServerDB.DatabaseName ) ;
878
886
;with cte as
879
887
(
880
888
SELECT dbo.tbXml.RevisionID, ISNULL(datalength(dbo.tbXml.RootElementXml), 0) as Uncompressed, ISNULL(datalength(dbo.tbXml.RootElementXmlCompressed), 0) as Compressed FROM dbo.tbXml
@@ -896,15 +904,15 @@ Param(
896
904
Inner Join tbBundleAtLeastOne t2
897
905
On t1.BundledID=t2.BundledID
898
906
Where ishidden=0 and pr.ExplicitlyDeployable=1
899
- )
900
- "
907
+ )"
901
908
902
- return Invoke-SQLCMD $SqlConnection $query $LogFile
909
+ return Invoke-SQLCMD $SqlConnection $query $LogFile
910
+ }
903
911
}
904
912
# endregion
905
913
906
914
$cmSiteVersion = [version ]" 5.00.8540.1000"
907
- $scriptVersion = " 2.4.7 "
915
+ $scriptVersion = " 2.4.8 "
908
916
$component = ' Invoke-DGASoftwareUpdateMaintenance'
909
917
$scriptPath = split-path - parent $MyInvocation.MyCommand.Definition
910
918
$IndexArray = @ {
@@ -965,11 +973,11 @@ If ($ConfigFile){
965
973
$Data [1 ]= $Data [1 ].Trim()
966
974
}
967
975
# Try to evaluate the value as an expression otherwise use the value as-is.
968
- Write-Verbose - Message " trying to Set Variable [$ ( $Data [0 ]) ] to [$ ( $Data [1 ]) ]"
976
+ Write-Verbose - Message " trying to Set Variable [$ ( $Data [0 ]) ] to [$ ( $Data [1 ]) ]"
969
977
Try {
970
978
If ($Data [0 ] -eq ' SiteCode' ) { # force a numeric SiteCode to be a string
971
979
Set-Variable - Name $Data [0 ] - Value ($Data [1 ] -as [string ]) - Force - WhatIf:$False
972
- } ElseIf ($Data [1 ] -match " ^@." ) {
980
+ } ElseIf ($Data [1 ] -match " ^@." -or $Data [ 1 ] -match " $* " ) {
973
981
Set-Variable - Name $Data [0 ] - Value (Invoke-Expression $Data [1 ]) - Force - WhatIf:$False
974
982
} ElseIf ($Data [1 ] -match " ^[0-9]*$" ) { # case where entire value is numeric
975
983
Set-Variable - Name $Data [0 ] - Value ($Data [1 ] -as [int ]) - Force - WhatIf:$False
@@ -1466,6 +1474,14 @@ $UpdatesToDecline = @{} #Hash table updates to decline.
1466
1474
$UpdatesToDelete = @ {} # Hash table updates to delete.
1467
1475
If ($DeleteDeclined -or $DeclineSuperseded -or $DeclineByTitle -or $DeclineByPlugins ){
1468
1476
1477
+ $WSUSServerDB = Get-WSUSDB $WSUSServer $LogFile
1478
+ If (! $WSUSServerDB )
1479
+ {
1480
+ Add-TextToCMLog $LogFile " Failed to get the WSUS database configuration." $component 3
1481
+ Set-Location $OriginalLocation
1482
+ Return
1483
+ }
1484
+
1469
1485
# Check the sync status.
1470
1486
If ($StandAloneWSUS ){
1471
1487
Invoke-WSUSSyncCheck $WSUSServer $LogFile
@@ -1508,12 +1524,15 @@ If ($DeleteDeclined -or $DeclineSuperseded -or $DeclineByTitle -or $DeclineByPlu
1508
1524
$ActiveUpdates = $AllUpdates | Where-Object {$_.IsDeclined -eq $False }
1509
1525
1510
1526
# Estimate catalog size
1511
- $CatalogInfo = Get-CatalogInfo $SqlConnection $ ($WSUSServerDB.DatabaseName ) $LogFile
1512
- $InitialCatlogSize = " Unknown"
1513
- $InitialCatlogSizeCompressed = " Unknown"
1514
- If ($CatalogInfo.Rows.Count -gt 0 ){
1515
- $InitialCatlogSize = $CatalogInfo.Rows [0 ].CatalogSize_MB
1516
- $InitialCatlogSizeCompressed = $CatalogInfo.Rows [0 ].CompressedCatalogSize_MB
1527
+ if ($WSUSServerDB )
1528
+ {
1529
+ $CatalogInfo = Get-CatalogInfo $WSUSServerDB $LogFile
1530
+ $InitialCatlogSize = " Unknown"
1531
+ $InitialCatlogSizeCompressed = " Unknown"
1532
+ If ($CatalogInfo.Rows.Count -gt 0 ){
1533
+ $InitialCatlogSize = $CatalogInfo.Rows [0 ].CatalogSize_MB
1534
+ $InitialCatlogSizeCompressed = $CatalogInfo.Rows [0 ].CompressedCatalogSize_MB
1535
+ }
1517
1536
}
1518
1537
1519
1538
# Initialize count variables.
@@ -1775,10 +1794,13 @@ If ($DeleteDeclined -or $DeclineSuperseded -or $DeclineByTitle -or $DeclineByPlu
1775
1794
}
1776
1795
1777
1796
# Restimate catalog size
1778
- $NewCatalogInfo = Get-CatalogInfo $SqlConnection $ ($WSUSServerDB.DatabaseName ) $LogFile
1779
- If ($NewCatalogInfo.Rows.Count -gt 0 ){
1780
- $InitialCatlogSize = $NewCatalogInfo.Rows [0 ].CatalogSize_MB
1781
- $InitialCatlogSizeCompressed = $NewCatalogInfo.Rows [0 ].CompressedCatalogSize_MB
1797
+ if ($WSUSServerDB )
1798
+ {
1799
+ $NewCatalogInfo = Get-CatalogInfo $WSUSServerDB $LogFile
1800
+ If ($NewCatalogInfo.Rows.Count -gt 0 ){
1801
+ $InitialCatlogSize = $NewCatalogInfo.Rows [0 ].CatalogSize_MB
1802
+ $InitialCatlogSizeCompressed = $NewCatalogInfo.Rows [0 ].CompressedCatalogSize_MB
1803
+ }
1782
1804
}
1783
1805
1784
1806
# Write the summary information.
@@ -1814,7 +1836,7 @@ If ($DeleteDeclined -or $DeclineSuperseded -or $DeclineByTitle -or $DeclineByPlu
1814
1836
Add-TextToCMLog $LogFile " Total Active Updates = $ ( $AllUpdates.Count - $DeclinedUpdates.Count - $countNewlyDeclined ) " $component 1
1815
1837
Add-TextToCMLog $LogFile " Total Updates = $ ( $AllUpdates.Count - $countNewlyDeleted ) " $component 1
1816
1838
If ($NewCatalogInfo.Rows.Count -gt 0 ){
1817
- Add-TextToCMLog $LogFile " Initial Catalog Size = $ ( $NewCatalogInfo.Rows [0 ].CatalogSize_MB) MB ($ ( $NewCatalogInfo.Rows [0 ].CompressedCatalogSize_MB) MB Compressed )" $component 1
1839
+ Add-TextToCMLog $LogFile " New Catalog Size = $ ( $NewCatalogInfo.Rows [0 ].CatalogSize_MB) MB ($ ( $NewCatalogInfo.Rows [0 ].CompressedCatalogSize_MB) MB Compressed )" $component 1
1818
1840
}
1819
1841
Add-TextToCMLog $LogFile " ========" $component 1
1820
1842
0 commit comments