none
Export a list of current list vaules

    Question

  • Hi,

    Can you please help as to how I either by a powershell script or Database Query.

    I have a custom list for Incidents, that is in a sealed management pack. I want to run a query that shows me all the current list vaules in that list.

    How do I do that from the database?

    Thanks

     

    Wednesday, September 15, 2010 12:25 AM

Answers

  • Hi

    Here's a powershell script that will do something like that. :)

    function getChildren([Microsoft.EnterpriseManagement.Configuration.ManagementPackEnumeration]$parent)
    {
     $outPut = "$outPut - " + $parent.DisplayName
     Write-host $outPut
     
     Foreach ($child in Get-SCSMEnumeration|?{$_.Parent -eq $parent})
     {
       getChildren $child
     } 
    } 
    
    Import-module smlets
    $rootEnumElementName = 'ChangeAreaEnum$'
    $parent = Get-SCSMEnumeration -Name $rootEnumElementName -ComputerName spiscsm1|?{$_.Parent -eq $enum}
    
    getChildren $parent
    

    You need to change the 'ChangeAreaEnum$' to reflect the root element of your custom lists internal name (you should leave the dollar sign on the end). Also, if you want to output the internal name of each element instead of the DisplayName then you need to change "DisplayName" to "Name".

    To get the internal name of your custom list root element you can run the following command but using the display name (as seen in the console) of your custom list instead of "Incident Classification":

    Get-SCSMEnumeration|?{$_.DisplayName -eq 'Incident Classification'}
    

    Patrik Sundqvist Solutions Architect http://blogs.litware.se
    Wednesday, September 15, 2010 2:21 PM
    Moderator

All replies

  • Hi

    Here's a powershell script that will do something like that. :)

    function getChildren([Microsoft.EnterpriseManagement.Configuration.ManagementPackEnumeration]$parent)
    {
     $outPut = "$outPut - " + $parent.DisplayName
     Write-host $outPut
     
     Foreach ($child in Get-SCSMEnumeration|?{$_.Parent -eq $parent})
     {
       getChildren $child
     } 
    } 
    
    Import-module smlets
    $rootEnumElementName = 'ChangeAreaEnum$'
    $parent = Get-SCSMEnumeration -Name $rootEnumElementName -ComputerName spiscsm1|?{$_.Parent -eq $enum}
    
    getChildren $parent
    

    You need to change the 'ChangeAreaEnum$' to reflect the root element of your custom lists internal name (you should leave the dollar sign on the end). Also, if you want to output the internal name of each element instead of the DisplayName then you need to change "DisplayName" to "Name".

    To get the internal name of your custom list root element you can run the following command but using the display name (as seen in the console) of your custom list instead of "Incident Classification":

    Get-SCSMEnumeration|?{$_.DisplayName -eq 'Incident Classification'}
    

    Patrik Sundqvist Solutions Architect http://blogs.litware.se
    Wednesday, September 15, 2010 2:21 PM
    Moderator
  • Wow, that was a useful post to find today, works a charm for me!

    Just remember also to change the -ComputerName spiscsm1 to reflect your server.

    Thanks Patrik!


    My System Center Blog
    Wednesday, September 15, 2010 3:18 PM
  • Hi Sal

    Since this worked for Steve I'm going to mark this as solved.


    Patrik Sundqvist Solutions Architect http://blogs.litware.se
    Monday, September 20, 2010 5:50 AM
    Moderator
  • This doesn't seem to work for SCSM 2012 SP1

    I can manually run the following command successfully:

    $parent = Get-SCSMEnumeration -Name $rootEnumElementName -ComputerName servername|?{$_.Parent -eq $enum}

    However I receive the following error when I attempt to run the script:

     Get-SCSMEnumeration? : The term 'Get-SCSMEnumeration?' is not recognized as
    the name of a cmdlet, function, script file, or operable program. Check the
    spelling of the name, or if a path was included, verify that the path is
    correct and try again.

    Thursday, July 18, 2013 6:55 PM
  • Hi,

    You must run this command before in order to proceed with script 


    import-module smlets

    Tuesday, January 6, 2015 7:17 PM
  • When execute show this message.

    PS C:\Windows\system32> Import-Module smlets
    Import-Module : The specified module 'smlets' was not loaded because no valid module
    file was found in any module directory.

    Not work for SCSM 2012 R2

    Get-SCSMEnumeration? : The term 'Get-SCSMEnumeration?' is not recognized as
    the name of a cmdlet, function, script file, or operable program. Check the
    spelling of the name, or if a path was included, verify that the path is
    correct and try again.

    Help Please!!

    Wednesday, February 11, 2015 3:47 PM
  • Wednesday, February 11, 2015 4:17 PM
  • Good job and many thanks for your effort.

    Now how can export the result in CSV file?
    Monday, August 8, 2016 10:58 AM