' Move SMS Reports to a Console Folder
Option Explicit
Dim objSWbemLocator
Dim objSWbemServices
Dim ProviderLoc
Dim Location
Dim objNewConsoleFolderItem
Dim FolderIdentifier
Dim objFolder
Dim ObjReport
FolderIdentifier=0
set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
set objSWbemServices= objSWbemLocator.ConnectServer _
("COMPUTER NAME", "root\sms")
Set ProviderLoc = objSWbemServices.InstancesOf("SMS_ProviderLocation")
For Each Location In ProviderLoc
If Location.ProviderForLocalSite = True Then
Set objSWbemServices = objSWbemLocator.ConnectServer _
(Location.Machine, "root\sms\site_" + Location.SiteCode)
End If
Next
For Each objFolder in objSWbemServices.InstancesOf("SMS_ObjectContainerNode")
if objFolder.Name="Hardware - Disk" Then FolderIdentifier=objFolder.ContainerNodeID
Next
If FolderIdentifier=0 Then
wscript.Echo "No Hardware - Disk folder found"
wscript.quit 2
End If
For Each objReport in objSWbemServices.InstancesOf("SMS_Report")
if objReport.Category="Hardware - Disk" Then 'Create the folder item.
Set objNewConsoleFolderItem = objSWbemServices.Get _
("SMS_ObjectContainerItem").SpawnInstance_()
objNewConsoleFolderItem.InstanceKey = ObjReport.SecurityKey
objNewConsoleFolderItem.ObjectType=8 ' Package Node.
objNewConsoleFolderItem.ContainerNodeID = FolderIdentifier 'Container
objNewConsoleFolderItem.Put_
End If
Next