You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Write-Warning"Unable to run this script due to missing dependency:`n`t`tSQL Server Powershell Module (https://docs.microsoft.com/en-us/sql/powershell/download-sql-server-ps-module)`n`nTry running this script on a SQL Server if you cannot download the Powershell Module."
30
-
break
31
+
Write-Warning"Unable to run this script due to missing dependency:`n`t`tSQL Server Powershell Module (https://docs.microsoft.com/en-us/sql/powershell/download-sql-server-ps-module)`n`nTry running this script on a SQL Server if you cannot download the Powershell Module."
32
+
break
31
33
}
32
-
34
+
foreach($machinein$MachineToRemove)
35
+
{
33
36
$bme_query=@"
34
37
--Query 1
35
38
--First get the Base Managed Entity ID of the object you think is orphaned/bad/needstogo:
36
39
--
37
-
DECLARE @name varchar(255) = '%$MachineToRemove%'
40
+
DECLARE @name varchar(255) = '%$machine%'
38
41
--
39
42
SELECT BaseManagedEntityId, FullName, DisplayName, IsDeleted, Path, Name
40
43
FROM BaseManagedEntity WHERE FullName like @name OR DisplayName like @name
Write-Host"Cleared $MachineToRemove from Pending Management List in SCOM Console."-ForegroundColor DarkGreen
125
+
Write-Host"Cleared $machine from Pending Management List in SCOM Console."-ForegroundColor DarkGreen
116
126
117
127
$purge_deleted_query=@"
118
128
--Query 5
119
129
--This query statement for SCOM 2012 will purge all IsDeleted=1 objects immediately
120
130
--Normally this is a 2-3day wait before this would happen naturally
121
-
--This only purges 10000 records. If you have more it will require multiple runs
131
+
--This only purges 10000 records. If you have more it will require multiple runs
122
132
--Purge IsDeleted=1 data from the SCOM 2012 DB:
123
133
DECLARE @TimeGenerated DATETIME, @BatchSize INT, @RowCount INT
124
134
SET @TimeGenerated = GETUTCDATE()
@@ -136,3 +146,4 @@ catch
136
146
{
137
147
Write-Error"Unable to Purge the Deleted Items from the OperationsManager DB`n`nCould not run the following command against the OperationsManager DB:`n$purge_deleted_query"
0 commit comments