Giuseppe Iannacone Posted January 14, 2019 Share Posted January 14, 2019 I was trying to update the expires date with the powershell module for hornbill, I've modified a script suggested in a post by @samwoo for disposal, but unfortunately it doesn't work. Can someone help me in understanding why? Script example # Import Hornbill XMLMC Powershell Module Import-Module D:\Asset_Hornbill\powershell\xmlmcModule.psm1 # Import from CSV file, the Asset Name column should be called - "Name" - or it can be changed in the script below $pathToCSV = "[Path for csv file].csv" $warrantyAssets = Import-Csv -path $pathToCSV foreach($asset in $warrantyAssets) { # Get the Asset Name from the name column in the CSV $assetName = "$asset.name" $date = (get-date("2015-07-15 00:00:00")).toString("yyyy-MM-dd hh:mm:ss") write-host $assetName write-host $date # Define instance connection details & API key for session authentication $hbInstance ="instancename" $hbZone = "eur" $hbAPIKey = "APIkey" Set-Instance -Instance $hbInstance -Key $hbAPIKey -Zone $hbZone # Build the API call to return the machines where the asset number matches in Hornbill Add-Param "application" "com.hornbill.servicemanager" Add-Param "entity" "Asset" Open-Element "searchFilter" Add-Param "column" "h_name" Add-Param "value" $assetName Close-Element "searchFilter" # Invoke XMLMC call, output returned as PSObject $hornbillAssetOutput = Invoke-XMLMC "data" "entityBrowseRecords2" # Convert the results of the API results into a workable format $hornbillAsset = $hornbillAssetOutput.Params.rowData.row # Update the Assets accordingly to warranty Add-Param "application" "com.hornbill.servicemanager" Add-Param "entity" "Asset" Open-Element "primaryEntityData" Open-Element "record" # Update the Asset matching the Name Add-Param "h_name" $assetName # Set the Warranty expiration date Add-Param "h_warranty_expires" $date Close-Element "record" Close-Element "primaryEntityData" # Invoke XMLMC call, output returned as PSObject $xmlmcAssetUpdate = Invoke-XMLMC "data" "entityUpdateRecord" } # Important! Remove XMLMC module from memory for security once XMLMC calls complete Remove-Module xmlmcModule Link to comment Share on other sites More sharing options...
Giuseppe Iannacone Posted January 15, 2019 Author Share Posted January 15, 2019 we were able to fix the issue, thanks anyway 1 Link to comment Share on other sites More sharing options...
samwoo Posted January 15, 2019 Share Posted January 15, 2019 I'm glad you were able to find a solution at @Giuseppe Iannacone. Powershell and Hornbill's API's can be so powerful. I wonder if there should be an area on the forums where we can share these sort of scripts? Link to comment Share on other sites More sharing options...
James Ainsworth Posted January 15, 2019 Share Posted January 15, 2019 You are always welcome to post them here: https://community.hornbill.com/forum/132-integration-connectors-api-webhooks/ @samwoo Link to comment Share on other sites More sharing options...
samwoo Posted January 16, 2019 Share Posted January 16, 2019 11 hours ago, James Ainsworth said: You are always welcome to post them here: https://community.hornbill.com/forum/132-integration-connectors-api-webhooks/ @samwoo ta - thanks @James Ainsworth 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