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

Issues when running script #7

Open smjb90 opened 6 years ago

smjb90 commented 6 years ago

ITGlue & PowerShell Noob... Please Help!

Hey Guys, Please see the below; Im not sure whats wrong an i'm now going round in circles.

Duplicate keys '' are not allowed in hash literals. At C:\Users\Administrator\desktop\ActiveDirectory.ps1:200 char:21

Invoke-RestMethod : {"errors":[{"status":"forbidden","title":"Cannot index flexible assets without providing a flexible asset type ID filter","source":{"pointer":null}}]} At C:\Program Files\WindowsPowerShell\Modules\ITGlueAPI\Resources\FlexibleAssets.ps1:67 char:20

CalebAlbers commented 6 years ago

Hi @smjb90,

Thanks for reaching out! It appears that $ADFunctionalLevel and some other variable is not being filled out properly. Would you be able to run the command (Get-ADForest).ForestMode and let me know what the output is?

Would you also mind checking your configuration file to see what value is set in key_name_ADFunctionalLevel = "...."? It appears that perhaps your config file got overwritten, or something else happened such that the script is unable to properly read and parse the parameters in the configuration file.

smjb90 commented 6 years ago

Thanks. When running Get-ADForest).ForestMode i get the returned value.
Windows2003Forest

@{

flexible_asset_type_id = '570897686905070'

key_name_ADForestName = 'forest-name'
key_name_DomainName = 'domain-full-name'
key_name_DomainShortName = 'domain-short-name'
key_name_SchemaMaster = 'schema-master'
key_name_DomainNamingMaster = 'domain-naming-master'
key_name_RIDMaster = 'relative-id-rid-master'
key_name_PDCEmulator = 'pdc-emulator-master'
key_name_InfrastructureMaster = 'infrastructure-master'
key_name_GlobalCatalogServers = 'global-catalog-servers-domain-controllers'
key_name_ADFunctionalLevel = 'ad-level'

}

Below is the name keys

forest-name domain-full-name domain-short-name ad-level schema-master domain-naming-master relative-id-rid-master pdc-emulator-master infrastructure-master global-catalog-servers-domain-controllers

smjb90 commented 6 years ago

@CalebAlbers

smjb90 commented 6 years ago

@CalebAlbers Any more thoughts on this? Thanks

mrbiggles0007 commented 5 years ago

I know nothing about powershell but I have a feeling it is because it is not getting the functional level of 2016 domains properly, it works on all others.

zebs1 commented 5 years ago

Had the same issue, fixed by a small edit to the file "ActiveDirectory.flexasset", line 19 (section AD Level)

From: Options: 2000, 2003, 2008, , 2008 R2, 2012, 2012 R2 To: Options: 2000, 2003, 2008, 2008 R2, 2012, 2012 R2

S1laRD commented 5 years ago

I'm getting the same on a 2012 R2 and 2016 domains. Have not tested others `Duplicate keys '' are not allowed in hash literals. At C:\Users\Admin\ActiveDirectory.ps1:200 char:17

I used the Initialize-ActiveDirectoryFlexAsset.ps1 script with the latest ActiveDirectory.flexasset file in the same folder to create the Active Directory asset Any ideas?

EDIT: I tried @zebs1's workaround but made no difference. I'm also getting the same error with the File Shares script

whiskeyhughes commented 5 years ago

Did you guys figure out a solution for this? I am getting the same exact error.

coltonmorrisonCHR commented 2 years ago

@CalebAlbers - This issue is still Open almost 4 years later. Why no solution?

CalebAlbers commented 2 years ago

@coltonmorrisonCHR I'm not an IT Glue employee - I built this in my free time several jobs ago and no longer work in the MSP industry or with Windows/PowerShell.

My guess would be that the call to retrieve AD functional level doesn't work as expected, I'd suggest starting there for debugging.

coltonmorrisonCHR commented 2 years ago

Sorry, @CalebAlbers, my mistake.