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

File shares info not writing to IT Glue, much like was happening with the AD one #13

Open jfpcc opened 5 years ago

jfpcc commented 5 years ago

There seems to have been an update to the ActiveDirectory.ps1 with the new Initialize-ActiveDirectoryFlexAsset.ps1 command being recently introduced. Is that accurate? Prior, trying the ActiveDirectory.ps1 ran fine but it never updated IT Glue. Now that this new command to ensure the AD Flex Asset is properly created, it runs just fine.

I'm having the same issues with the FileShares.ps1. It seems to be grabbing all the correct info about file shares on the server that is run, but never actually writes to IT Glue and gives no error. Any suggestions?

image

I'll have a peak at the Initialize-ActiveDirectoryFlexAsset.ps1 code in the meantime.

Thanks,

ckortenhorst commented 5 years ago

I am getting no errors just showing me in green under each share

File Shares flex asset configuration file found!

But nothing showing in IT-Glue

theonlytruebigmac commented 5 years ago

Same thing is happening to me, anything new in here?

mikekanet commented 5 years ago

It appears that it wasn't passing the org_id information to the correct part of the script. I was able to force it to work by changing line 232 in the FileShares.ps1 script to be as follows: $api__org_id = "nnnnnn" You would need to manually enter your org id in place of nnnnnn. Once I manually put in the org_id it worked for me. Now the only problem is that if I run it more than one time it duplicates the file shares, instead of updating. Any guidance on that would be great.

ni82156 commented 5 years ago

Mikekanet, after I make that change I get the error

C:\fileshares\FileShares.ps1 : ERROR: File Shares flex asset configuration file was found. Please create one and re-run the script. At line:1 char:1

ni82156 commented 5 years ago

Nevermind, figured out the solve for my earlier comment but still not working overall. Everything is green it just doesn't put the data in IT Glue

Absoblogginlutely commented 5 years ago

There are a couple of bugs in the fileshares.ps1 file but after fixing those so I have correct data I now get New-ITGlueFlexibleAssets : {"errors":[{"status":401,"title":"Unauthorized","detail":"Unauthorized resource access","source":{"pointer":"id"}}]} At C:\jobs\itglue\FileShares.ps1:245 char:49

Code is currently $api__body = formatAPIData # format data for API call $api__org_id = $api__body.data.attributes.organization_id $api__flex_asset_id = $api_config.flex_asset_id

Should be `$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.flex_asset_id
                    $api__flex_asset_id = $api_config.flexible_asset_type_id
                    `

This will at least now poplate api__body. Looking as to why this is unauthorised?

Absoblogginlutely commented 5 years ago

I also found a couple of instances for the server/diskpath where it looks like the code was expecting the routine to be run against multiple machines. However the samples /command line show it being run against one machine. As a result, looping through server results in referencing an array when there is only one value so $currentserver=$server[$i] ends up as a null value instead of the current server name. The same can be said with the diskpath.

After I changed the above, i still find that the $api__body.attributes.traits.servers is blank after the $api_body = formatapidata is called. At that point $post has the server name in it, but the server gets lost when api_body is created. I manually set it in the script but I'm still getting the unauthorised resource access.