Giuseppe Iannacone Posted November 9, 2020 Share Posted November 9, 2020 I used to use the powershell API module (https://github.com/hornbill/powershellHornbillAPIModule/blob/master/xmlmcModule.psm1) to massively update some data in our asset management. has been a while since i used it but now the same script i used succesfully is returning an error. Link to comment Share on other sites More sharing options...
SamS Posted November 9, 2020 Share Posted November 9, 2020 Hi @Giuseppe Iannacone, I'm not absolute sure, but the error message suggests that somehow $h_id isn't set correctly. What happens if you output $h_id separately. Another item of note: "entityBrowseRecords" has been marked as "deprecated" for a while. You might want to look into using "entityBrowseRecords2" instead. Link to comment Share on other sites More sharing options...
Steve G Posted November 9, 2020 Share Posted November 9, 2020 Hi @Giuseppe Iannacone, This is basically saying that the value in your $h_id varible is null, and you can't .Trim() a null. This would suggest that either no records have been returned by your call to entityBrowseRecords, or more than one has (so row would be an array of PSObjects rather than a flat PSObject), in which case you need to handle either of those outcomes in your script. Cheers, Steve Link to comment Share on other sites More sharing options...
Giuseppe Iannacone Posted November 9, 2020 Author Share Posted November 9, 2020 @Steve Gand @SamS while I understand your point it makes no sense to me, while this was working before and I'm sure I have only 1 ID for the Name provided. can I send you privately (via forum inbox) the script for a review? Link to comment Share on other sites More sharing options...
Giuseppe Iannacone Posted November 9, 2020 Author Share Posted November 9, 2020 @SamS I've now read more carefully your post and it seems like I'm using a deprecated method, where i can find info for the supported one "entityBrowseRecords2" Link to comment Share on other sites More sharing options...
Giuseppe Iannacone Posted November 9, 2020 Author Share Posted November 9, 2020 @Steve G and @SamS following your suggestion tu use "entityBrowseRecords2" it seems to me that i have to adjust this part of the script for the "searchFilter": so the script should be adjusted in something like this (but I'm not understanding which is the column that i have to search for) Link to comment Share on other sites More sharing options...
Steve G Posted November 9, 2020 Share Posted November 9, 2020 @Giuseppe Iannacone, The column you are searching for looks to be correct, but I'd suggest you also add the matchType property to the searchFilter parameter, and set it to exact, as by default this is set to wildcard. Thanks, Steve Link to comment Share on other sites More sharing options...
Giuseppe Iannacone Posted November 9, 2020 Author Share Posted November 9, 2020 @Steve G still a blank ID I'm going slightly mad same error no ID returned... what am I still doing wrong? Link to comment Share on other sites More sharing options...
Steve G Posted November 9, 2020 Share Posted November 9, 2020 Hi @Giuseppe Iannacone, I've just given this a whirl, the HornbillAPI module is working as expected, but there are a number of issues with your script - all calls to Open-Element, Close-Element and Add-Param should be replaced by the correct cmdlets: Open-HB-Element, Close-HB-Element and Add-HB-Param otherwise you wont be sending any payload to the API. I wrote the following very basic script as an example, using v1.1.0 of the Hornbill API module, which searches for an exact match and includes some very basic handling of when a record is not found. This is when it's successfully found a matching asset: And when an asset record is not returned: Hope this helps, Steve Link to comment Share on other sites More sharing options...
Giuseppe Iannacone Posted November 9, 2020 Author Share Posted November 9, 2020 @Steve G I will give it a try, thanks where I can find this info? I've tried into the wiki but to me it seem there are not... would be very useful, for the time being thanks again. Link to comment Share on other sites More sharing options...
Giuseppe Iannacone Posted November 10, 2020 Author Share Posted November 10, 2020 13 hours ago, Steve G said: using v1.1.0 of the Hornbill API module @Steve G I'm unable to find this version of the module both on wiki or github Link to comment Share on other sites More sharing options...
Steve G Posted November 10, 2020 Share Posted November 10, 2020 Hi @Giuseppe Iannacone, The latest versions of the HornbillAPI and HornbillHelpers modules can be viewed in the PowerShell Gallery: https://www.powershellgallery.com/packages/HornbillAPI/1.1.0 https://www.powershellgallery.com/packages/HornbillHelpers/1.1.1 From PowerShell, run the following commands: Install-Module -Name HornbillAPI Install-Module -Name HornbillHelpers And this will install the latest versions on to your machine. The Github version is old, and should be deprecated - I'll do this now, thanks. Cheers, Steve Link to comment Share on other sites More sharing options...
Giuseppe Iannacone Posted November 10, 2020 Author Share Posted November 10, 2020 @Steve Gthank you, where this info can be found? it is "odd" that the wiki still refers to the github repo, and would be nice to have such update when they come trough thank you! Link to comment Share on other sites More sharing options...
Steve G Posted November 10, 2020 Share Posted November 10, 2020 @Giuseppe Iannacone No worries. Sorry, I didn't realise that old Github repo was linked on the wiki, I'll get that updated too. We moved the PowerShell modules over to the PowerShell Gallery a good while ago, so that we had a single module source for both Windows and Azure PowerShell, rather than maintaining two codebases. If you visit the module pages linked above, and expand Package Details, you will get a list of the cmdlets exported by the module: And if you expand FileList and click on the psm1 file, this will show you the cmdlet sourcecode, with documentation contained within for each of the exported cmdlets. See the below for Add-HB-Param: Cheers, Steve Link to comment Share on other sites More sharing options...
Giuseppe Iannacone Posted November 10, 2020 Author Share Posted November 10, 2020 @Steve G thank you for the info, now I'm able to correctly run an api call with powershell. Can you please help me with the remaining part of the script... I would like to mass update state and substate for an asset Link to comment Share on other sites More sharing options...
Giuseppe Iannacone Posted November 11, 2020 Author Share Posted November 11, 2020 @Steve G I'm sorry to push on this, but it will be very useful to understand why it's not working or better the "h_record_state" is correctly updated but not the substate Thank you! Link to comment Share on other sites More sharing options...
Steve G Posted November 11, 2020 Share Posted November 11, 2020 @Giuseppe Iannacone, Is the substate value not being updated in the record, if you were to check it in Database Direct? What about if you populate the h_substate_name field too? I'm not sure how the interface works in this app, so maybe @ArmandoDM would be best placed to assist, as this isn't an issue with the module... Thanks, Steve Link to comment Share on other sites More sharing options...
ArmandoDM Posted November 11, 2020 Share Posted November 11, 2020 @Giuseppe Iannacone the asset substate is set in the properties h_substate_id and h_substate_name. Of course, make sure that the substate exists; check the table h_cmdb_asset_substate. Thank you Armando 1 1 Link to comment Share on other sites More sharing options...
Giuseppe Iannacone Posted November 11, 2020 Author Share Posted November 11, 2020 @ArmandoDM & @Steve G thank you very much, this has sorted out my issue. here is the remaining portion of the script for people in the forum to check out 1 Link to comment Share on other sites More sharing options...
ArmandoDM Posted November 12, 2020 Share Posted November 12, 2020 Ciao @Giuseppe Iannacone Glad to hear that's sorted out now. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now