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 Script doesn't update config file or ITGlue #3

Open globier opened 6 years ago

globier commented 6 years ago

I've just started to test the scripts, the Active directory script works well.
But when I run the DHCP script , it outputs the correct information to screen but I've found that the $api variable isn't initiated.

I've added it to the parameters section which got past that but now I'm getting Method invocation failed because [System.Net.IPAddress] does not contain a method named 'op_Addition'. \DHCP\DHCP.ps1:121 char:5

I'm not great with powershell so any help appreciated.

arpeake commented 6 years ago

I have not invested time in the DHCP script yet, hopefully Caleb can assist with it before I can get around to it.

If I have time before Christmas I will take a look at it.

On December 20, 2017 9:16:29 PM EST, globier notifications@github.com wrote:

I've just started to test the scripts, the Active directory script works well.
But when I run the DHCP script , it outputs the correct information to screen but I've found that the $api variable isn't initiated.

I've added it to the parameters section which got past that but now I'm getting Method invocation failed because [System.Net.IPAddress] does not contain a method named 'op_Addition'. \DHCP\DHCP.ps1:121 char:5

I'm not great with powershell so any help appreciated.

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/itglue/automation/issues/3

-- Sent from my Android device with K-9 Mail. Please excuse my brevity.

CalebAlbers commented 6 years ago

Hey Globier,

I'll take a look tonight.

Out of curiosity, what version of PowerShell are you using, and on what operating system? You can find your PS version by opening a terminal and typing $PSVersionTable.PSVersion.

On Wed, Dec 20, 2017, 9:17 PM arpeake notifications@github.com wrote:

I have not invested time in the DHCP script yet, hopefully Caleb can assist with it before I can get around to it.

If I have time before Christmas I will take a look at it.

On December 20, 2017 9:16:29 PM EST, globier notifications@github.com wrote:

I've just started to test the scripts, the Active directory script works well. But when I run the DHCP script , it outputs the correct information to screen but I've found that the $api variable isn't initiated.

I've added it to the parameters section which got past that but now I'm getting Method invocation failed because [System.Net.IPAddress] does not contain a method named 'op_Addition'. \DHCP\DHCP.ps1:121 char:5

I'm not great with powershell so any help appreciated.

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/itglue/automation/issues/3

-- Sent from my Android device with K-9 Mail. Please excuse my brevity.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/itglue/automation/issues/3#issuecomment-353247543, or mute the thread https://github.com/notifications/unsubscribe-auth/AGx9-vYDhec74E8KvKvQAOfNSQKckFwtks5tCc3bgaJpZM4RJRB7 .

globier commented 6 years ago

I've made sure I updated so Major Minor Build Revision


5 1 14409 1005

Thanks Guys

globier commented 6 years ago

Server 2012 R2

CalebAlbers commented 6 years ago

Hey Globier,

I just wanted to chime in and say that I haven't forgotten this. I was out earlier in the week for Christmas, but am back now.

I found some aspects of the script could be executed better and in a way that hopefully is more compatible. I'm rewriting the script completely and will send it your way after testing.

On Wed, Dec 20, 2017, 9:37 PM globier notifications@github.com wrote:

Server 2012 R2

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/itglue/automation/issues/3#issuecomment-353250000, or mute the thread https://github.com/notifications/unsubscribe-auth/AGx9-jrrHw6eM879kjF6qMYuD4N_XrfRks5tCdKHgaJpZM4RJRB7 .

jhill777 commented 6 years ago

Hello, Is this supposed to be functioning correctly yet? Mine displays all the correct scopes and stuff but doesn't update ITG.

Thanks in advance.

Andrewconcisemsp commented 6 years ago

I get the same problem.

dmiller90 commented 6 years ago

@globier @jhill777 @Andrewconcisemsp change the $apibody from $apibody = @{ data = @{ type = "flexible_assets" attributes = @{ organization_id = $apiorg_id flexible_asset_type_id = $api_config.flexible_asset_type_id traits = @{ $apikey_name_ScopeName = $Name $apikey_name_Server = $apiServer_id $api__key_name_ScopeBounds = $Start + "-" + $End } } } }

to.... $apibody = @{ data = @{ type = "flexible_assets" attributes = @{ organization_id = $apiorg_id flexible_asset_type_id = $api_config.flexible_asset_type_id traits = @{ $apikey_name_ScopeName = $Name $apikey_name_Server = $api__Server_id $api__key_name_ScopeBounds = "$Start-$End" } } } }

its the $api__key_name_ScopeBounds line causing the error, the + signs

Andrewconcisemsp commented 6 years ago

@dmiller90 thanks for that. I Still get the same issue. It finds the correct information and display's it but then never updates IT Glue.

dmiller90 commented 6 years ago

@Andrewconcisemsp can you send me the error you are seeing

Andrewconcisemsp commented 6 years ago

Hi @dmiller90 thanks for replying. I do not get an error. It runs ok, shows all the relevant information as seen below but then never updates the flexible asset. See powershell commands and all relevant files attached also. api_config-DHCP.zip

capture

Let me know if you need anything else.

dmiller90 commented 6 years ago

@Andrewconcisemsp Do you have a flex asset type for DHCP? i dont see the ID in your config file nor do i see one listed?

Or are you trying to post this info under your AD asset type? If so fill in flexible_asset_type_id = '' with flexible_asset_type_id = '412206168932595' in your config file

Daniel

Andrewconcisemsp commented 6 years ago

Hi @dmiller90 Apologies for the delay in getting back to you. I am putting it into the AD Asset Type. I filled in the ID and the asset still does not get updated. I have also filled in the correct org_id manually and still get the same problem. It finds all the relevant information but the flexible asset never gets updated. Andrew

jbusschers commented 5 years ago

I think two thinks are missing in the code:

[string]$api = "", and change $apikey_name_ScopeBounds = $Start + "-" + $End to $apikey_name_ScopeBounds = "$Start-$End" so dmiller says.

But with these changes there is no error on the script, but the information is not updating in IT Glue