Server Management Suite

 View Only
  • 1.  Retrieve the folder structure in NS console for resources (ie. filters, policies, etc.)

    Posted Mar 08, 2012 11:30 AM

    We are migrating from 7.0 to 7.1 and I want to write several queries that will determine the exact filters, etc. along with their exact folder path in the NS console so we can easily find them to migrate them over.  I know that vFolder, ItemReference, and vCollections are the key but I can't figure out what links them all together.  If someone has a query or knows the query to pull this information it would be very valuable to a lot of people.  Especially if you can plug in different resource types.  Thanks.

     

     

    Here are some queries to get others started but I'm stumped:

     

    Select hint, count(hint) as [hintcount]
    From ItemReference
    group by hint
    order by [hintcount] desc
     
     
    select hint, count(hint) as [hintcount]
    from itemreference
    where childitemguid IN (select guid
    from vFolder) or parentitemguid IN (select guid
    from vFolder)
    group by hint
    order by [hintcount] desc
     
     
    select *
    from vCollection


  • 2.  RE: Retrieve the folder structure in NS console for resources (ie. filters, policies, etc.)

    Posted Mar 08, 2012 12:08 PM

    I'd be quite interested in the same info......   here's how far I've gotten trying to find a list of all filters, but I've ended up getting a bit more than that.

    The querry returns folder structure of nestled folders, including policies and filters.  I haven't yet figured out how to confine it to policies or filters.

    It is rather sad that one can't easily get this info out of the console,  it makes migrating quite difficult to figure out that you have the same content in both places.

    SELECT
    fd.[Name] [Folder]
    ,it.[Name] [MSD Policy Name]
                  
     FROM vItem it
    JOIN ItemFolder ifd ON ifd.[ItemGuid] = it.[Guid]
    JOIN vFolder fd ON fd.[Guid] = ifd.[ParentFolderGuid]
    WHERE it.[ClassGuid] = 'F1E8956A-A158-487F-8185-4C3B492734E7'
    AND it.[Attributes] = '0'
    ORDER BY [Folder], [MSD Policy Name]



  • 3.  RE: Retrieve the folder structure in NS console for resources (ie. filters, policies, etc.)

    Posted Mar 12, 2012 09:35 PM

    The migration wizard isn't an option here?



  • 4.  RE: Retrieve the folder structure in NS console for resources (ie. filters, policies, etc.)
    Best Answer

    Posted Mar 15, 2012 09:11 PM

    OK, this SQL will list all Resources with the specified Class Guid(s) and the folder path to where they reside.  By default, it will list all user-created Managed Delivery Policies.  I also included the Guid for Filters if you want to change it to that (in the comments).  Hopefully the comments make sense, if not, feel free to ask. :)

    This might be a little overkill, using the nested SQL Cursors and all, but it works :)

     

     

    DECLARE @ResourceName NVARCHAR(MAX)
    DECLARE @BaseFolderGuid UNIQUEIDENTIFIER
    DECLARE @FolderPath NVARCHAR (MAX)
    DECLARE @ParentFolderGuid UNIQUEIDENTIFIER
    DECLARE @Count INT
    DECLARE @Folder NVARCHAR (MAX)
    DECLARE @Results TABLE ([Resource] NVARCHAR(MAX), [Path] NVARCHAR (MAX))
     
    SET @FolderPath = NULL
    SET @ParentFolderGuid = NULL
    SET @Count = 0
    SET @BaseFolderGuid = NULL
    SET @ResourceName = NULL
     
    DECLARE resourceCursor CURSOR
    FOR
    SELECT it.[Name], fd.Guid
    FROM vNonResourceItem it
    JOIN ItemFolder ifd ON ifd.[ItemGuid] = it.[Guid]
    JOIN vFolder fd ON fd.[Guid] = ifd.[ParentFolderGuid]
    WHERE 1 = 1
    /***********************************************************************************************
    * This is the key filter that determines which resources are included in the search.  
    * By default, it is Managed Software Delivery policies (there are 2 Class Guids required to get ALL Managed Delivery policies)
    * If you wish to find all Filters, then you would substitute the Guid 'AECA2D91-C615-4D99-BAD5-612CA159DA4F'
    *************************************************************************************************/
    AND it.[ClassGuid] IN ('2D3A170E-5028-4570-BA0C-3DB775CB8BDE','212E1D10-4905-4CDB-A90A-81AE77E9DE9A') --Change Resource Guids here!!
     
    /***********************************************************************************************
    * This filter only includes items which are User created.  Comment out this line if you 
    *  wish to include items created by the SMP as well.
    *************************************************************************************************/
    AND it.[Attributes] = 0
     
     
     
    /*************************************************************************************************
    * Nested SQL cursors to iterate through all resources returned by previous query. Second cursor
    *  iterates through the folder structure in which the resource resides and builds a single Path
    *
    * No user modification required if changing the ResourceType above
    *************************************************************************************************/
    OPEN resourceCursor
    FETCH NEXT FROM resourceCursor
    INTO @ResourceName, @BaseFolderGuid 
       WHILE @@FETCH_STATUS = 0
       BEGIN
     
       DECLARE myCursor CURSOR
       FOR SELECT ParentFolderGuid FROM FolderBaseFolder WHERE FolderGuid = @BaseFolderGuid ORDER BY Depth DESC
     
       SET @FolderPath = ''
       SET @Folder = ''
       OPEN myCursor;
       FETCH NEXT FROM myCursor INTO @ParentFolderGuid
          WHILE @@FETCH_STATUS = 0
          BEGIN
             IF @ParentFolderGuid <> 0x
             BEGIN
             SET @Folder = (SELECT Name
             FROM vFolder
             WHERE Guid = @ParentFolderGuid)
             SET @FolderPath = @FolderPath + '/' + @Folder
          END
       FETCH NEXT FROM myCursor INTO @ParentFolderGuid
       END
       CLOSE myCursor
       DEALLOCATE myCursor
       INSERT INTO @Results
       VALUES(@ResourceName, @FolderPath)
       SET @Count = (@Count + 1)
    FETCH NEXT FROM resourceCursor INTO @ResourceName, @BaseFolderGuid
    END
    CLOSE resourceCursor
    DEALLOCATE resourceCursor
     
    SELECT * FROM @Results


  • 5.  RE: Retrieve the folder structure in NS console for resources (ie. filters, policies, etc.)

    Posted Mar 16, 2012 10:57 AM

    You ROCK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!   Your method is sooooooo much better than what I was doing.

    I ended up with a nasty SQL with alot of AND fd.[Name] NOT LIKE 'FolderName'  to eliminate the unwanted folders.  

    Is there a way to get packages from this same report structure? I ended up creating organizational groups to differentiate the packages (test, prod, retired, etc)

    The end game I am after is a series of reports which can be combined in excel and uses vlookups to get  packages = Policies = filters
     



  • 6.  RE: Retrieve the folder structure in NS console for resources (ie. filters, policies, etc.)

    Posted Mar 16, 2012 12:37 PM

    Software packages are no longer shown in the SMP Console and therefore have no folder structure.  A separate query could be built to list all packages and their locations (http, unc, local, etc.), but again, there is no folder structure that can be obtained.



  • 7.  RE: Retrieve the folder structure in NS console for resources (ie. filters, policies, etc.)

    Posted Apr 17, 2012 12:26 PM

    I forgot I posted this.  :)  I was searching google again for the same question and lo and behold I come across my own post with actual responses.  Thank you so much, this works great!