' 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


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

For Each objFolder in objSWbemServices.InstancesOf("SMS_ObjectContainerNode")
    if objFolder.Name="Hardware - Disk" Then FolderIdentifier=objFolder.ContainerNodeID

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 _
        objNewConsoleFolderItem.InstanceKey = ObjReport.SecurityKey
        objNewConsoleFolderItem.ObjectType=8 ' Package Node.
        objNewConsoleFolderItem.ContainerNodeID = FolderIdentifier 'Container
    End If
search for scripts

VbsEdit contains all these sample scripts!

Download Now!

Download   Home   Scripts

Copyright © 2001-2023 adersοft