Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Wrote below code to get response from API


PowerShell
$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)


PowerShell
$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.
Posted
Updated 29-Jul-21 22:08pm
v2

1 solution

Quote:
Need some suggestions on how to do this.
Here you go ... some suggestions[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900