Skip to content

Instantly share code, notes, and snippets.

@jhanley-com
Created August 7, 2020 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhanley-com/03ba5dd65a0cb9611173dd090c6a80b2 to your computer and use it in GitHub Desktop.
Save jhanley-com/03ba5dd65a0cb9611173dd090c6a80b2 to your computer and use it in GitHub Desktop.
@set APIKEY=your_cloud_api_key
@set URI=https://clients.hostwinds.com/cloud/api.php
@set FILENAME=instances.json
@if exist %FILENAME% del %FILENAME%
@curl %URI% ^
-sS ^
-X POST ^
-d "action=get_instances&API=%APIKEY%" > %FILENAME%
@if %errorlevel% equ 0 (
@REM - Print instance names
@echo Instances
@echo IP OS ServerName Hostname
@echo ----------------------------------------------------------------------
@cat %FILENAME% | jq -r ".success | .[] | [.main_ip, .image.name, .srvrname, .hostname] | @tsv" 2>error.log
@if %errorlevel% equ 0 (
@echo.
@echo ------------------------------
@echo Success
) else (
@REM @echo Exit Code is %errorlevel%
@echo Failed
@cat %FILENAME% | jq
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment