Wrote below code to get response from API
$url = "https://dd.st.s-domain.net/wapi/v2.10.5/ipv4address?network=**$subnet**&_return_as_object=1"
$pwd = ConvertTo-SecureString "password" -AsPlainText -Force
$creds = New-Object Management.Automation.PSCredential ('user', $pwd)
$Result_IPAddress = Invoke-RestMethod -Uri $url -Method Get -Credential $creds -Headers $headers -ContentType 'application/json'
I am executing this code for each subnet which i am passing in the
$url and getting the ipaddresses under that subnet (10.15.9.0/23)
$IPAddress = $Result_IPAddress.result.ip_address
$IPStatus = $Result_IPAddress.result.status
The data is coming like below in the variables
$IPAddress
10.15.9.0
10.15.9.1
10.15.9.2
10.15.9.3
10.15.9.4
10.15.9.5
10.15.9.6
$IPStatus
UNUSED
UNUSED
UNUSED
UNUSED
UNUSED
UNUSED
UNUSED
I need to create an excel file with
$subnet(10.15.9.0/23) as sheet name and then these data
IPAdreess Status
10.15.9.0 UNUSED
10.15.9.1 UNUSED
10.15.9.2 UNUSED
10.15.9.3 UNUSED
10.15.9.4 UNUSED
10.15.9.5 UNUSED
10.15.9.6 UNUSED
What I have tried:
Need some suggestions on how to do this.