akamai / akamaipowershell

Powershell module for Akamai {OPEN} APIs
Apache License 2.0
23 stars 14 forks source link

Update List-HostnamesInContract.ps1 #40

Open pablolurquilopez opened 1 year ago

pablolurquilopez commented 1 year ago

Hi, thanks for the work, but was failing (to me) using PS 7.2 till I added the @() as an array. Hope this helps.

stuartio commented 1 year ago

Hey, thanks for the PR. Can you tell me which version of Powershell you use, and which Akamai account please? I would like to reproduce the error

pablolurquilopez commented 1 year ago

Hi!

Sorry, my bad, I told you 7.3.1?. I ran from ISE:

Major Minor Build Revision


5 1 20348 1366

I was running without making it array:

PS C:\Users[USER]> $PropHostnames = List-PropertyHostnames -GroupID $Property.groupId -ContractId $Property.contractId -PropertyId $Property.propertyId -PropertyVersion $Property.LatestVersion -Section $Section -AccountSwitchKey $AccountSwitchKey No se puede convertir el valor "@{cnameType=EDGE_HOSTNAME; cnameFrom=[CORRECT FQDN]; cnameTo=failover.edgesuite.net; certProvisioningType=CPS_MANAGED}" al tipo "System.Collections.ArrayList". Error: "No se puede convertir el valor "@{cnameType=EDGE_HOSTNAME; cnameFrom=[CORRECT FQDN]; cnameTo= failover.edgesuite.net; certProvisioningType=CPS_MANAGED}" de tipo "System.Management.Automation.PSCustomObject" al tipo "System.Collections.ArrayList"." En línea: 1 Carácter: 1

When modifying to "@([......])"

PS C:\Users[USER]> $PropHostnames = @(List-PropertyHostnames -GroupID $Property.groupId -ContractId $Property.contractId -PropertyId $Property.propertyId -PropertyVersion $Property.LatestVersion -Section $Section -AccountSwitchKey $AccountSwitchKey)

PS C:\Users[USER]> $PropHostnames

cnameType cnameFrom cnameTo certProvisioningType



EDGE_HOSTNAME [CORRECT FQDN] failover.edgesuite.net CPS_MANAGED

I am afraid I cannot provide you the AKAMAI account as I am not the owner. But there are several groups and properties in each one.

Let me know where I made the mistake, and accept my apologies if so!

Best regards,

Pablo

El mié, 18 ene 2023 a las 17:34, Stuart Macleod @.***>) escribió:

Hey, thanks for the PR. Can you tell me which version of Powershell you use, and which Akamai account please? I would like to reproduce the error

— Reply to this email directly, view it on GitHub https://github.com/akamai/akamaipowershell/pull/40#issuecomment-1387358832, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEMV7MCDJXP2XN4URP7ZGO3WTALRHANCNFSM6AAAAAAT7ISJ3Q . You are receiving this because you authored the thread.Message ID: @.***>

stuartio commented 1 year ago

Thanks for the info @pablolurquilopez . I am trying to narrow down the problem, but I suspect the issue is with Powershell's sometimes annoying habit of converting single-item arrays into just an object of that single item. It tends to confuse PS 5. Can you tell me the email address you use to log in to Akamai please? I can try it against your Akamai access to more easily narrow it down. Also these scripts are pretty old and I can make them way more efficient now, so will overhaul them shortly. If you want to list all hostnames in a given account, check out Get-AppSecHostnameCoverage. I think that would give you the whole list, though not which property, group and contract each hostname is associated with.