Tools and Tips for SCCM and SCOM

Collection of SCCM Console Right Click Tools

Writen by Rick Houchins at myITforum.com. To download 1.9 version click here

Get Local and AD Groups, installed products and system roles

@echo off

:: by Neven Radic, Dec-15-2009

:: It will gather variety informations like Local Group

:: membership, installed application and roles, AD computer account

:: membership, applied GPO etc.  

:: #############################################################################

 

if exist c:\%COMPUTERNAME%_Groups.txt del c:\%COMPUTERNAME%_Groups.txt
set parm=Localgroup
Echo Geting Server basic informatin ...
Echo COMPUTERNAME =  %COMPUTERNAME% >>c:\%COMPUTERNAME%_Groups.txt
Echo ALVer = %ALVer% >>c:\%COMPUTERNAME%_Groups.txt
Echo USERDNSDOMAIN = %USERDNSDOMAIN% >>c:\%COMPUTERNAME%_Groups.txt
Echo. >>c:\%COMPUTERNAME%_Groups.txt
Echo Where a computer is in AD: >>c:\%COMPUTERNAME%_Groups.txt
dsquery computer -name %computername% >>c:\%COMPUTERNAME%_Groups.txt
Echo. >>c:\%COMPUTERNAME%_Groups.txt
Echo What groups computer is a member of: >>c:\%COMPUTERNAME%_Groups.txt
dsquery computer -name %computername% | dsget computer -memberof >>c:\%COMPUTERNAME%_Groups.txt

Echo ------------------------------------------------------- >>c:\%COMPUTERNAME%_Groups.txt
Echo. >>c:\%COMPUTERNAME%_Groups.txt

Echo Geting Server installed products ...
WMIC /APPEND:c:\%COMPUTERNAME%_Groups.txt PRODUCT
Echo ------------------------------------------------------- >>c:\%COMPUTERNAME%_Groups.txt
Echo. >>c:\%COMPUTERNAME%_Groups.txt
Echo Geting Server roles ...
ServerManagerCmd.exe -query >>c:\%COMPUTERNAME%_Groups.txt
Echo ----------------------------------------------------- >>c:\%COMPUTERNAME%_Groups.txt
Echo. >>c:\%COMPUTERNAME%_Groups.txt
Echo Geting Server Local Groups Members ... >>c:\%COMPUTERNAME%_Groups.txt
Echo ------------------------------------------------------- >>c:\%COMPUTERNAME%_Groups.txt
Echo. >>c:\%COMPUTERNAME%_Groups.txt
for /F "tokens=*" %%* in ('net localgroup ^| find "*"') do call :Sub %%*
set parm=Group
REM Run only on DC
:: for /F "tokens=*" %%* in ('net groups /domain ^| find "*"') do call :Sub %%*
notepad c:\%COMPUTERNAME%_Groups.txt
goto :eof
:Sub
set name=%*
echo Group name: %name%
echo %parm% name: %name:~1% >> c:\%COMPUTERNAME%_Groups.txt
net %parm% "%name:~1%" | find /i /v "completed successfully" | more +6 >>c:\%COMPUTERNAME%_Groups.txt 

List all installed updates in one line:

wmic qfe list full /format:htable

How to create a collection excluding members from another collection.

The answer to that question is based on the knowledge that every collection you make in SCCM creates its own wmi class. The class will be named sms_cm_ress_coll_collectionid.
To create exclusion
1) Create your collection
2) Add a query based membership rule to your collection
3) Edit the query statement of the collection
4) On the criteria tab add a criteria
5) For the attribute class select System Resource, and use Resource Id for the attribute
6) For the criteria type use subselect
7) For the operator select "Not In"
8) In the query box type select resourceid from sms_cm_res_coll_collectionid.

Now we need to figure out the collection id,:
In SCCM 2007, the new admin UI in Configmgr 2007 has the collectionid written down on the properties page of every collection. The flexible approach by using the sms_cm_ress_coll_collectionid for building collections is still very valid though. This approach is usually used whenever someone is looking for the reverse option of "collection limiting" collections.
Or by   prompted query to easily find the collectionid based on the collection name. Here is how you create the query.

1) Go to queries
2) Right-click and select new query
3) Make sure you specify <unspecified> in the Object type dialog.
4) Press the Edit Query button
5) Paste the following query in the Query statement box that opens up:
select collectionid, name from sms_collection where name like ##PRM:SMS_collection.Name##
Note: You can use the _ and % wildcard signs when you input the collection name.