Jump to content


Search the Community

Showing results for tags 'add to collection'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Cloud
    • Azure
    • Microsoft Intune
    • Office 365
    • Windows 365
  • General Stuff
    • General Chat
    • Events
    • Site News
    • Official Forum Supporters
    • Windows News
    • Suggestion box
    • Jobs
  • MDT, SMS, SCCM, Current Branch &Technical Preview
    • How do I ?
    • Microsoft Deployment Toolkit (MDT)
    • SMS 2003
    • Configuration Manager 2007
    • Configuration Manager 2012
    • System Center Configuration Manager (Current Branch)
    • Packaging
    • scripting
    • Endpoint Protection
  • Windows Client
    • how do I ?
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows Vista
    • Windows XP
    • windows screenshots
  • Windows Server
    • Windows Server General
    • Active Directory
    • Microsoft SQL Server
    • System Center Operations Manager
    • KMS
    • Windows Deployment Services
    • NAP
    • Failover Clustering
    • PKI
    • Hyper V
    • Exchange
    • IIS/apache/web server
    • System Center Data Protection Manager
    • System Center Service Manager
    • System Center App Controller
    • System Center Virtual Machine Manager
    • System Center Orchestrator
    • Lync
    • Application Virtualization
    • Sharepoint
    • WSUS

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Location


Interests

Found 1 result

  1. Hi guys hope you can help me found this HTA a wile ago and im trying to adapt it to sccm2012 but my hta skills are bit Noob based, can you help me my mission is to have desktop support to be able to add machine to collections thats basicaly defined by myself. Change this to match your setup ("<SMSSERVERNAME> or <SMSSQLServer>","root\SMS\site_<SMS SITE CODE>") Add Computer to Collection.hta <head> <title>Add computers to Collection</title> <body background = "background.jpg"> Add Computer to Collection <BR> <hr> <HTA:APPLICATION ID="Addcompcol" APPLICATIONNAME="Addcomputer" SCROLL="NO" SINGLEINSTANCE="yes" WINDOWSTATE="normal" SYSMENU="no" > </head> <script language="VBScript"> Sub Closeme window.close() end sub Sub Window_Onload window.moveTo 200,200 window.resizeto 500,500 'width x height end sub </script> <body onload=Window_Onload onkeypress="Checkenter"> <script language="VBScript"> On error resume next Set Shell = CreateObject("Wscript.Shell") Set oFSO = CreateObject("Scripting.FileSystemObject") Set SWbemLocator=CreateObject("WbemScripting.SWbemLocator") set SWbemServices = SWbemLocator.ConnectServer("<SMSSERVERNAME> or <SMSSQLServer>","root\SMS\site_<SMS SITE CODE>") If Err.Number Then Err.Clear Closeme() End If sub search() count=0 if findcomp.value <> "" Then strQuery = "select * from SMS_CM_RES_COLL_SMS00001 where name like '%"& findcomp.value &"%'" Set Computers= SWbemServices.ExecQuery(strQuery) strHTML= strHTML & "<select size=""6"" name=""Computerlisting"" multiple width:200"">" for each Computer in Computers count=count+1 if count<50 then ' strHTML= strHTML & "<BR>" & Computer.Name ' msgbox Computer.ResourceID strHTML= strHTML & "<option value="& Computer.ResourceID &">"& Computer.Name &"</option>" End if Next Output.InnerHTML = strHTML End if end sub '''''''''''''''' Sub Checkenter If window.event.Keycode = 13 Then search() End If End Sub sub searchcollection() count=0 if findcoll.value <> "" Then strQuery = "select * from SMS_Collection where name like '%"& findcoll.value &"%'" Set Collections= SWbemServices.ExecQuery(strQuery) strHTML= strHTML & "<select size=""6"" name=""Collectionlisting"" multiple width:300"">" for each Collection in Collections count=count+1 if count<50 then ' strHTML= strHTML & "<BR>" & Computer.Name ' msgbox Computer.ResourceID strHTML= strHTML & "<option value="& Collection.CollectionID &">"& Collection.Name &"</option>" End if Next strHTML= strHTML & "</select><BR><hr>" strHTML= strHTML & "<input type=""button"" value=""Add to Collection"" onClick=""addcomputers"">" OutputCol.InnerHTML = strHTML End if end sub sub addcomputers() '''''''' For Each Computerselect in Computerlisting.Options if Computerselect.Selected then ComputerResourceID = Computerselect.value ' this is the resource value of the computer selected end if Next '''''''' For Each Collectionselect in Collectionlisting.Options if Collectionselect.Selected then collectionquery = "SMS_Collection.CollectionID='"&Trim(Collectionselect.value)&"'" Set oCollection = SWbemServices.Get(collectionquery) Set newDirectRule = SWbemServices.Get("SMS_CollectionRuleDirect").SpawnInstance_ newDirectRule.ResourceClassName = "SMS_R_System" newDirectRule.ResourceID = ComputerResourceID ' Add the new query rule to a variable. Set oCollectionRule = newDirectRule oCollection.AddMembershipRule oCollectionRule end if Next '''''''''' 'oCollection.RequestRefresh True strHTML="Computer has been added!" Output.InnerHTML = "" OutputCol.InnerHTML = strHTML end Sub '''''''''''''''' Sub Checkentercollection If window.event.Keycode = 13 Then searchcollection() End If End Sub </script> Computer Name Search <input type="value" style="background-color:#ffb7d6" name="findcomp" size="20" > <input type="button" value="OK" name="acceptcomp" onClick="search" style="background:red; "> <BR> <hr> <span id="Output"></span> <BR> <HR> Collection Name Search <input type="value" style="background-color:#ffb7d6" name="findcoll" size="20" > <input type="button" value="OK" name="acceptcoll" onClick="searchcollection" style="background:red; "> <BR> <hr> <span id="OutputCol"></span> <input type="button" value="Close Window" name="Closeout" onClick="Closeme" style="background:white; "> </body>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.