Tuesday 7 October 2014

SCCM Report for Local administrator group





To be able to run this report you have to edit your MOF file first. So please make abackup of your working MOF and test this one in a test environment.

******************************************************



Smsdef.mof

//  <:[-<>>>>>>>>>>>>>>>>>>>>>>>>>>>Begin>>-Administrators group-<<Begin<<<<<<<<<<<<<<<<<<<<<<<<>-]:>

#pragma namespace ("\\\\.\\root\\cimv2\\sms")
[ SMS_Report (TRUE),SMS_Group_Name ("LocalAdmins"),SMS_Class_ID ("MICROSOFT|LocalAdmins|1.0")]
class Win32_LocalAdmins : SMS_Class_Template
{
[SMS_Report(TRUE), key] string AccountName;
[SMS_Report(TRUE), key] string GroupName;
};

//  <:[-<>>>>>>>>>>>>>>>>>>>>>>>>>>>END>>-Administrators group-<<END<<<<<<<<<<<<<<<<<<<<<<<<>-]:>


Config.sms

#pragma namespace ("\\\\.\\root\\cimv2")
[union, ViewSources{"Select * from Win32_GroupUser where GroupComponent=\"Win32_Group.Domain='BUILTIN',Name='Administradores'\""},ViewSpaces{"\\\\.\\root\\CIMV2"}, Dynamic : ToInstance, provider("MS_VIEW_INSTANCE_PROVIDER")]
class Win32_LocalAdmins
{
[PropertySources("PartComponent"), key] Win32_Account ref AccountName;
[PropertySources("GroupComponent"), key] Win32_Group ref GroupName;
};
*****************************************



-Then you can run this report:


************************************************

select 
distinct Name0 as 'Computer Name', substring(AccountName0,charindex('Domain=',Accountname0)+8,(charindex('Name=',Accountname0)-charindex('Domain=',Accountname0)-10)) as 'Domain Name', substring(AccountName0,len(AccountName0)-charindex('"',reverse(AccountName0),2)+2,charindex('"',reverse(AccountName0),2)-2) as 'User Name'
from v_GS_SYSTEM INNER JOIN v_GS_LocalAdmins ON v_GS_SYSTEM.ResourceID = v_GS_LocalAdmins.ResourceID

**********************************************


3 comments:

  1. While these are helpful, details on how specifically to utilize this information would probably be paramount for what seems to be your target audience (newer SCCM administrators), js

    ReplyDelete
  2. At the beginning this was like a sort of "backup" of all scripts I used on day by day....you know not to forget. I think sharing some of this experience is good as I needed when I was at the beginning. Soon I would like to share more procedures like package creation and more SCCM administration procedures.

    Anyway, thanks for feedbak I appreciate.

    ReplyDelete
  3. Thank you so much for posting this. It was very helpful, as we had need for this report

    ReplyDelete

Give me you feedback!