itglue / automation

A place for IT Glue's user community to learn ways of automating their documentation.
Apache License 2.0
99 stars 33 forks source link

DHCP / File Shares Not Uploading to IT Glue #15

Open firefox15 opened 5 years ago

firefox15 commented 5 years ago

Hey, thanks for these scripts. I know it's all volunteer time, so I do not want to act like you owe me any troubleshooting, but if you have a minute, I'm having an issue with the DHCP and file share scripts. The AD script works great--no issues there.

Basically, both scripts say they are running, but no information is uploaded to IT Glue. Are there any levels of verbose logging I can enable to try to troubleshoot this more?

File Shares flex asset configuration file found! Users$ ------ Organization Name:
Server: Server01 Share Name: Users$ Share Path: \\Server01\Users$ Share Description:
Disk Path: D:\users

qcomer commented 5 years ago

We are having the same problem

skoefel commented 5 years ago

Same here

mettix commented 5 years ago

Same here -_-

mettix commented 5 years ago

I got the solutions! I'll try to figure out how I can post an update.. :x

mettix commented 5 years ago

https://github.com/mettix/automation/blob/master/File%20Shares/FileShares.ps1

Here I forked this thing, updated script is there.

Absoblogginlutely commented 5 years ago

I tried @mettix 's script to see if that would make a difference for me. The data displayed when the script is run looks correct (which is a big improvement over the original script) however I'm still getting New-ITGlueFlexibleAssets : {"errors":[{"status":401,"title":"Unauthorized","detail":"Unauthorized resource access","source":{"pointer":"id"}}]} At C:\jobs\File Shares\FileShares.ps1:244 char:49

I am able to update the AD flexible asset, office365 etc using the sample file so I know write API access is working correctly

Absoblogginlutely commented 5 years ago

I got this working by changing some logic. tldr - set Permissions to the notes field.

In my case, permissions is set not as a description field but a security group tag. As ITGlue expects a the permissions to be a tag, it generates the permission denied when sending free text to the Permissions tab. I fixed this by setting my api_config-fileshares.psd1 to read as follows. @{ org_id = '12345' flexible_asset_type_id = '54321'

key_name_ShareName = 'share-name'
key_name_ShareDescription = 'share-description'
key_name_Server = 'servers'
key_name_SharePath = 'share-path'
key_name_DiskPath = 'disk-path'
#key_name_Permissions = 'required-security-group'
key_name_Permissions = 'notes'

}

The data was then quickly uploaded to ITGlue. However, a similar issue occurs with the Servers field. I was kind of expecting this to be the text for the servername ie the computers hostname, but again this is a tag field so does not work. If I grab the servers id from the url and hard code it just before the set-itglueflexibleassets line, the update to ITGlue works.

What I did find in my testing is that right now it creates a new share every time the script is run instead of editing the existing share, AND there is no mass delete option in ITGlue to delete all the Flexible assets at once. This is because the only checking is to see if an organization exists. If it does, then New-ITGlueFexibleAsset is called as opposed to checking if the asset exists and if it does then running a patch. if(test-path $api) { $api_config = Import-LocalizedData -FileName "$api"

                    Write-Host "File Shares flex asset configuration file found!" -ForegroundColor Green

                    $api__body = formatAPIData # format data for API call
                    ######$api__org_id = $api__body.data.attributes.organization_id
                    $api__org_id = $api__body.attributes.organization_id
                    $api__flex_asset_id = $api_config.flexible_asset_type_id
                   ##This is where i've hard coded the server number for now instead of using a server text value.

$apibody.attributes.traits.servers="19818167" if($apiorg_id) { Write-Host "Creating a new flexible asset." $api__output_data = New-ITGlueFlexibleAssets -data $api__body } } else { Write-Error "ERROR: File Shares flex asset configuration file was found. Please create one and re-run the script." }

Still working on debugging this script..

rlnenicka commented 5 years ago

I am not great with powershell not going to lie, I am however pretty decent with VB so my solution was to simply run these with the -file argument and then wrote an exe to upload the output :) a little hacky i know but why reinvent the wheel since these pull the info i'm looking for (although i'm thinking I will just eliminate the need for them all together so a single exe is all that is needed, but who has the time, right lol). it will likely be a bit before i have a finished product but the core functionality is there, just needs to be prettied up. Once complete, I'd be happy to share if anyone is interested.