Home Asset Management

Trying to import Enumerations for HW Asset Types and not finding how to do this

Thomas_StickelThomas_Stickel Customer IT Monkey ✭
I have a csv file that has the column headers of    Parent | Enumerations | Ordinal  
1. I have been able to import other things like Vendors and Organizations just fine
2. This is not the main HW Assets, but its the enumerations - so when I go to Administration - Connectors and add a new Connector, I don't need in the Target Class and Combination Class a dropdown for the HW Asset Types , thus I don't know how to add these enumerations.   

Thoughts?

Best Answer

  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭
    edited May 2019 Answer ✓
    @Thomas_Stickel - Ordinal is necessary.  It's the order in which the list values are displayed.  

    It is likely that powershell can't handle the special characters without some additional edits to the script. 

    I'd like to point out that this is not a typical way to introduce list values.  Although it's possible to use this script, it's more typical(and may actually require less effort) to enter the list values manually through the console.

Answers

  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭
    @Thomas_Stickel - You wouldn't use an Asset Import connector for list values.  You typically have to enter list values manually.  It would be possible though to write a powershell script to consume your CSV.
  • Thomas_StickelThomas_Stickel Customer IT Monkey ✭
    Hi Justin.  thx
    1. What exactly would I update?  I almost prefer to do an SSIS ETL to import into a table ... but I think I'm severity lacking the knowledge of the schemas.   
    2. Would there be a specific Table to import into that you know of  ( Microsoft's servicemanager database? )   
    3. If you are not familiar with the table structure ( i'm sure that sure are  though)    - can you give me an example of how I can import this with powershell ?  
    4.   Parent | Enumerations | Ordinal  
            Computer  | Desktop  |     1
            Infrastructure | Blade   |    7

    thanks in advance
  • Thomas_StickelThomas_Stickel Customer IT Monkey ✭
    Ok - so I found that in Service Manager Console - Library - Lists      That seems to be what i want to add to , the "Hardware Asset Type"   -  noticed a video showing how adding an xml file and csv import will actually work for list (enum) imports  -  thus it seems that I just need to find an example and create a new xml file (management pack ?  that maps to the columns in the csv and then that will import it seems  ,  right  ?
  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭
    Yes.  Management Packs are basically XML files that SCSM uses to manage data.  List values are rendered in Management Packs.  
    Just a note on your previous question: editing the SQL tables directly is inadvisable as that leaves your SCSM environment in an unsupported state for Microsoft. 

    I'm working on a powershell method of bringing enum values in by consuming your CSV.
  • Thomas_StickelThomas_Stickel Customer IT Monkey ✭
    Thanks Justin. I am definitely avoiding the tables directly as i figured that is a bad idea with this type of product etc..    Ok  - so having many different options will be great - the powershell for sure .  However - for the creating of a proper xml management pack for things like this list values for hw asset types - I'm sort of struggling to find to how write it etc..    Any example on that MP format  - where to find examples and how to do it?   thx again

  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭
    You don't normally have to write Management Packs manually.  You can add the list values as needed manually through Library/Lists.  SCSM will prompt you to create a Management Pack.
  • Thomas_StickelThomas_Stickel Customer IT Monkey ✭
    I was watching a video earlier and the person adding an enum list clicked  Administration --> connectors --> on the right side they clicked on "Import from CSV file"  in which that requires browsing to a XML format file AND the data file (csv)   .   that seems to be knowing how to create the xml MP ...    but otherwise yesterday i was instead creating a new connector ... then new management pack and browse to csv  and fill out the form. 

    Problem is that I didn't see the enum list in the Connectors ...    So where can i have SCSM create a management pack for me for the HW Asset Types  (enum lists)   ?  thx
  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭
    Can you provide a link to the video?
  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭
    @Thomas_Stickel - It looks like that video was talking about importing work items not Enum List values.  He did reference this enum creation spreadsheet:
    https://techcommunity.microsoft.com/t5/System-Center-Blog/Create-List-Items-aka-EnumerationValues-In-Bulk-Using/ba-p/341420?advanced=false&collapse_discussion=true&q=create%20list%20items%20in%20bulk&search_type=thread

    Here's a link to some powershell that will consume a CSV(attached as well for a reference).  I haven't tested it super-thoroughly, but it does seem to be functional and effective.  It's hardcoded for Hardware Asset Type, but it could be adapted for other Enums.
  • Thomas_StickelThomas_Stickel Customer IT Monkey ✭
    Thanks Justin.   Looking at the powershell now.     Regarding the video - correct it was working with Incidents, but part of the title was "

    CSV Imports for Enumeration Lists 

  • Thomas_StickelThomas_Stickel Customer IT Monkey ✭
    Justin - since I need to import enums for several different areas - seems the hard parts for me are mostly not knowing the names of classes etc..   example  - "Cireson.AssetManagement.HardwareAssetTypeEnum."  etc..  ,   Moving forward I suppose powershell I could do for this , but I almost would like to do it with xml -  either way it seems that I don't know the proper names of the objects.    e.g.  I knew that I needed to import Hardware Asset Type , but how would i know to use the name "Cireson.AssetManagement.HardwareAssetTypeEnum"   then the same goes for other enums etc..     thx again
  • Thomas_StickelThomas_Stickel Customer IT Monkey ✭
    Ok, the only thing I changed in the ps1 are   1.  my excel is Enumeration and not Enumerations for the column header ,  thus 6 edits.
    Then I added the path to the CSV file.   This is the powershell error that I received .  thoughts?

    At E:\AssetFiles\HardwareAssetType.ps1:16 char:19
    + ...        $p = Add-SCSMEnumeration -Parent $hwaType -Name ("Cireson.Asse ...
    +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Add-SCSMEnumeration], ManagementPackException
        + FullyQualifiedErrorId : Microsoft.EnterpriseManagement.Common.ManagementPackException,SMLets.AddSCSMEnumerationCommand
     
    Add-SCSMEnumeration : Verification failed with 1 errors:
    -------------------------------------------------------
    Error 1:
    Found error in 2|CompanyName.ListValues.HWA.Type|1.0.0.0|CompanyName.ListValues.HWA.Type|| with message:
    XSD verification failed for the management pack. [Line: 0, Position: 0]
    System.Xml.Schema.XmlSchemaValidationException: The 'ID' attribute is invalid - The value 'Cireson.AssetManagement.HardwareAssetTypeEnum.Conference Room' is invalid 
    according to its datatype 'ManagementPackUniqueIdentifier' - The Pattern constraint failed. ---> System.Xml.Schema.XmlSchemaException: The Pattern constraint failed.
       --- End of inner exception stack trace ---
       at System.Xml.Schema.XmlSchemaValidator.SendValidationEvent(XmlSchemaValidationException e, XmlSeverityType severity)
       at System.Xml.Schema.XmlSchemaValidator.CheckAttributeValue(Object value, SchemaAttDef attdef)
       at System.Xml.Schema.XmlSchemaValidator.ValidateAttribute(String lName, String ns, XmlValueGetter attributeValueGetter, String attributeStringValue, XmlSchemaInfo 
    schemaInfo)
       at System.Xml.XsdValidatingReader.ValidateAttributes()
       at System.Xml.XsdValidatingReader.ProcessElementEvent()
       at System.Xml.XsdValidatingReader.Read()
       at Microsoft.EnterpriseManagement.Configuration.XSDVerification.ValidateManagementPack(TextReader mpcontents, ManagementPack mp, Boolean throwError)
    -------------------------------------------------------
    At E:\AssetFiles\HardwareAssetType.ps1:18 char:17
    + ...             Add-SCSMEnumeration -Parent $p -Name ("Cireson.AssetManag ...
    +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Add-SCSMEnumeration], ManagementPackException
        + FullyQualifiedErrorId : Microsoft.EnterpriseManagement.Common.ManagementPackException,SMLets.AddSCSMEnumerationCommand
  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭
    @Thomas_Stickel - I have added a newer version of the script that is a bit more flexible.  I think the issue with your first pass is the space in your Enum Value.  You can safely include spaces now as the script accounts for it and they'll be properly rendered in the DisplayName. 

    What I do to find the proper name of enums is just go into powershell and do something like "get-scsmenumeration classification" (ie for Incident Classification) This might bring back way more than you wanted, but you can reason out through the returned values what is the root enum and provide that to the script.  I would make sure to include a $ at the end of the enum name though because if you don't, the call to get-scsmenumeration will bring back multiple results and the script will fail later on because the $enum variable will be an array and not a single enum.
  • Thomas_StickelThomas_Stickel Customer IT Monkey ✭
    Thanks Justin.   I think it ended adding duplicates since other items were still there so I deleted manually , and re-run.   I guess I need to figure out what to write to not let duplicates happen.  Thoughts?
  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭
    I'd probably look at Adminstration/Management Packs in the SCSM console and just delete the first one you created with the script.  That doesn't stop the script from making duplicates moving forward, but it should be a relatively quick way to get a clean import.
  • Thomas_StickelThomas_Stickel Customer IT Monkey ✭
    Ok, I will look at that.   For the most part the goal is for a few people to maintain assets after I get it all loaded ... so bear with me.    For HW asset , there is a "Model"  in which we want a list loaded for this .  
    example is 

    Model 
    HP DL320p Gen 8 
    ProLiant BL460c G7   
    .....

    1. How do I find what the name of the $mpName and $enum (yes i know those names are variables and can be anything, but just for reference on your powershell script)   should be  ?  
    2. Then the names in the foreach specific  -  well i suppose it mostly just uses the combination of the variables and looping over and if there is nested objects ( which in this name of the models.csv  that is not the case)  

    thx again in advance Justin.      -  Soon I will leave you alone  :)     thx

  • Thomas_StickelThomas_Stickel Customer IT Monkey ✭
    So based on my last comment / questions  ..

    Where do i find the equivalent of these for Models?

    $mpName = "CompanyName.ListValues.HWA.Type"
    $enum = Get-SCSMEnumeration -Name Cireson.AssetManagement.HardwareAssetTypeEnum$

    Administration/ManagementPacks doesn't seem to show  Cireson.AssetManagement.HardwareAssetTypeEnum
  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭
    $mpName is the name of the Management Pack the script is generating.  The list values are stored in the resulting management pack. 
    $enum is the enum you're looking for.  In the case of Asset type, it's the Enum that's in the script.  In the case of Model, it's Cireson.AssetManagement.CatalogItemModelEnum.  Like I said above, you can find the name of the Enum you're looking for by doing a get-scsmenumeration in powershell with some relevant part of the name acting as a search pattern. (ie get-scsmenumeration model)
  • Thomas_StickelThomas_Stickel Customer IT Monkey ✭
    Ok, so I see that   get-scsmenumeration model returns the following 2 names

    Cireson.AssetManagement.CatalogItemModelEnum Catalog Item Model
    Cireson.AssetManagement.ConsumableModelEnum  Consumable Model

    I know to use the first one.   However for Models should it look like this?

    (management pack  mpName i'm still not sure about how to find that one   , but the $enum should be correct i think) 

    $mpName = "CompanyName.ListValues.HWA.Type"  ?   Well actually ListValues.?  
    $enum = Get-SCSMEnumeration -Name Cireson.AssetManagement.CatalogItemModelEnum$

    thx again 
  • Thomas_StickelThomas_Stickel Customer IT Monkey ✭
    MP is  HWA.Type   for the hardware types,   but how do i find the name for the MP for Model      HWA.Model or HWA.CatalogItemModel  ?    how do i find this ? 
  • Thomas_StickelThomas_Stickel Customer IT Monkey ✭
    Justin , It seems with the Models , I still need to use Ordinal?  I do get some data to enter into the system... but then 1. it skips some records, 2. crashes with errors   
    I modified the other powershell script that you gave to me and i ended up in the foreach loop with just this line

    Add-SCSMEnumeration -Parent $enum -Name ($enum.Name + "." + $t.Model.Replace(' ','')) -DisplayName $t.Model -Ordinal 10 -ManagementPack $mp

    Clearly I must be needing to 
    1. Have a way of handling Ordinal  ( I tried to put in 1 and then 10 )   otherwise if i omit it, i will prompt me to enter a number on each loop 
    2. perhaps i will also need to look to escape certain characters?  example :   Intel(R) Xeon(R) CPU E5640 @ 2.67GHz   

    thx again   ( yes  i believe i understand ur saying "$mpName is the name of the Management Pack the script is generating."   thus i can literally make it up ...  )   

    thx  tom
  • Justin_WorkmanJustin_Workman Cireson Support Super IT Monkey ✭✭✭✭✭
    edited May 2019 Answer ✓
    @Thomas_Stickel - Ordinal is necessary.  It's the order in which the list values are displayed.  

    It is likely that powershell can't handle the special characters without some additional edits to the script. 

    I'd like to point out that this is not a typical way to introduce list values.  Although it's possible to use this script, it's more typical(and may actually require less effort) to enter the list values manually through the console.
Sign In or Register to comment.