Open ecspresso opened 5 years ago
Hi @ecspresso every time i try and run the script i am getting the following error and any assistance would be appreciated.
Set-ITGlueFlexibleAssets : {"errors":[{"status":422,"title":"Unprocessable Entity","detail":"Request contains invalid trait keys","source":{"pointer":"data/attributes/traits"}}]} At C:\scripts\ITGLUEHyperV\ITGlue-VMHost-FeedFlexibleAssetHyperV.ps1:396 char:26
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Set-ITGlueFlexibleAssets
I looked at all the trait keys in both files, I think the problem is force manual sync
. Either rename it in the asset to force manual sync now
or change all the references in the sync script. It should be on line 314 and 347:
'force-manual-sync-now' = 'No'
-> 'force-manual-sync' = 'No'
if($flexibleAsset.data.attributes.traits.'force-manual-sync-now' -eq 'Yes') {
-> if($flexibleAsset.data.attributes.traits.'force-manual-sync -eq 'Yes') {
Let me know it if works.
Microsoft Hyper-V sync
This submission contains three scripts and one readme with instructions. The end result will sync the following to its asset in IT Glue:
The script will look for changes on the host compared to IT Glue and only update if a change is detected, there is also an option to manually force an update by setting "Force manual sync now" to "Yes". It will try to match each VM against a configuration in the organization where the VM Host flexible asset resides. IT will first try matching via name and then via MAC address. If the matching succeeds, a clickable link will be created in place of its name. If the matching fails, the name will be in plain text. It will also create a related item for each matched configuration (and remove it again if the VM is deleted from the host).
ITGlue-VMHost-CreateFlexibleAsset.ps1
This script will create a flexible asset type to hold the data. You will need to create a flexible asset for each server to sync.
ITGlue-VMHost-Setup.ps1
This script will prepare the environment on the server by (if not already saved) saving the API key and data center location via the wrapper module settings and creating a scheduled task to run the syncing script once every day.
ITGlue-VMHost-FeedFlexibleAssetHyperV.ps1
This is the script that will do the actual syncing. It will not run unless you have at least PowerShell version 3 and ITGlueAPI PowerShell wrapper version 2.0.7 installed. How to run the script is each to their own and it is possible to provide all the parameters inside the script file but there is no need to edit this script if following the provided instructions.
hyperv-related-items.txt
This file is created by
ITGlue-VMHost-FeedFlexibleAssetHyperV.ps1
. Because there is no endpoint to get related items and their IDs, the file is created to store the last reponse from the endpoint create related items. The data is imported the next time the script is run if found and all current VMs are matched aganst IT Glue and then compared aginst old related items. All configurations no longer on the host are removed.