poniedziałek, 5 marca 2018

How to check which binaries can be removed from SCCM server

    Recently I received an interesting question - can particular folders from the SCCM source share be removed or are they still in use by any application? It can be actually verified with a below SQL query, which helps to identify all folders set as a source for any application or package and matching a certain wildcard chosen by an administrator.


Exemplary output of the folder presence SQL query

Usage:
    Replace the _ServerFQDN_ string with the name of the source server, XXX$ with a name of the share and YYY with a regular expression matching a path to the folders you want to verify. 
    Obviously the query should be run via SQL Management Studio or any other similar tool letting you execute T-SQL queries.

Code:
SELECT Name,PkgSourcePath,ContentSource FROM v_Content
JOIN v_Package ON v_Package.PackageID = v_Content.PkgID
WHERE ContentSource LIKE '\\_ServerFQDN_\XXX$\YYY\%'
OR PkgSourcePath LIKE '\\_ServerFQDN_\XXX$\YYY\%'