Showing posts with label sql. Show all posts
Showing posts with label sql. Show all posts

Wednesday, February 8, 2012

For a specific Advertisement status for last 3 Days…

---for a specific Advertisement status for last 3 Days… if we include the Set   @AdvName = '%' line then and remove the above line in red color will show for all advertisements with last 3 days status

-- To include all we need to give % in SQL this is a tip

Declare     @AdvName Varchar(256)
Set   @AdvName = 'Lync_2010_Full_Install'

---Set   @AdvName = '%'  
Select      adv.AdvertisementName
,    adv.AdvertisementID
,    s.Host
,    LastAcceptanceMessageIDName
,    LastAcceptanceStateName
,    LastAcceptanceStatusTime
,    LastStatusMessageIDName
,    LastStateName
,    LastStatusTime
,    LastExecutionResult
From  (
      Select      AdvertisementName
      ,    AdvertisementID
      From  dbo.v_AdvertisementInfo
      Where AdvertisementName Like @AdvName
      ) As  adv
Join  (
      Select      AdvertisementID
      ,    ResourceID
      ,    LastAcceptanceMessageIDName
      ,    LastAcceptanceStateName
      ,    LastAcceptanceStatusTime
      ,    LastStatusMessageIDName
      ,    LastStateName
      ,    LastStatusTime
      ,    LastExecutionResult
      From  dbo.v_ClientAdvertisementStatus
      Where LastStatusTime >= DateAdd(d,-3,GetDate())
      ) As  cas
On    adv.AdvertisementID = cas.AdvertisementID
Join  (
      Select      ResourceID
      ,    Netbios_Name0 As Host
      From  dbo.v_R_System
      Where Client0 = 1
      And  Active0 = 1
      And  Obsolete0 = 0   
      ) As  s
On    cas.ResourceID = s.ResourceID
Order By
      AdvertisementName
,    Host

HeartBeat Discovery Status of specific collection of systems

select
    CS.Name0,
    max(AD.AgentTime) as 'Date/Time'
from
    dbo.v_AgentDiscoveries ad
    JOIN dbo.v_GS_COMPUTER_SYSTEM cs on AD.ResourceID = CS.ResourceId
    join dbo.v_FullCollectionMembership FCM on FCM.ResourceID = CS.ResourceId
Where
    AgentName = 'Heartbeat Discovery'
    and FCM.CollectionID = 'SMS00001'
Group by
    CS.Name0

Friday, January 27, 2012

AD computer Numbers vs SCCM Computer Numbers

read here more http://smsug.ca/blogs/garth_jones/archive/2008/12/03/how-to-add-ad-data-to-configmgr-reporting.aspx

AD it just another database, just like SQL server is. With that in mind there is nothing stopping you from using SQL to link to AD to give you data about your AD environment!

1) Create Linked Server using SSMS

exec master.dbo.sp_addlinkedserver 'ADSI', 'Active Directory Service Interfaces', 'ADSDSOObject', '<DC Name FQDN>'

2) Modify the security for ADSI using SSMS

exec master.dbo.sp_addlinkedsrvlogin @rmtsrvname = N'ADSI', @locallogin = NULL , @useself = N'False', @rmtuser = N'<Domian>\<User Id>', @rmtpassword = N'<Password>'

3) The hard part is over!

4) Create query to query AD and ConfigMgr

This query will list all PCs within AD that are NOT within ConfigMgr (or SMS)

select

AD.cn as 'PC Name(AD)',

AD.operatingSystem as 'OS (AD)',

AD.operatingSystemServicePack as 'SP (AD)'

from

openquery (ADSI,

'SELECT cn,

operatingSystem,

operatingSystemServicePack

FROM ''LDAP://<DC Name FQDN>''

WHERE objectCategory = ''Computer''') as AD

Where

AD.cn not in (Select name0 from v_GS_Computer_System as CS)

order by

AD.cn,

AD.operatingSystem,

AD.operatingSystemServicePack

This query will give you a count of all OS that are NOT within ConfigMgr (or SMS)

select

AD.operatingSystem as 'OS (AD)',

count(AD.operatingSystem)

from

openquery (ADSI,

'SELECT cn,

operatingSystem,

operatingSystemServicePack

FROM ''LDAP://gartek-dc.gartek.tst''

WHERE objectCategory = ''Computer''') as AD

Where

AD.cn not in (Select name0 from v_GS_Computer_System as CS)

Group by

AD.operatingSystem

order by

AD.operatingSystem

So what does this report look like.

image

So there you have it.

Wednesday, April 20, 2011

Did you checked what is the log file of SCCM DB ? or did you checked what is the backup size and why it is increasing ?

Did you checked what is the log file of SCCM DB ? or did you checked what is the backup size and why it is increasing ?

 

Yes it is because of transaction log size increase … check below query to know the size of the log files….

 

 

 

SELECT name,size from sys.database_files


output:-

name                         size
SMS_SiteCode           662576
SMS_SiteCode_log     3541704