Skip to content

Instantly share code, notes, and snippets.

@houey
Created May 10, 2024 14:06
Show Gist options
  • Save houey/ab0175831fdba7e8371e8bc32e75e1d4 to your computer and use it in GitHub Desktop.
Save houey/ab0175831fdba7e8371e8bc32e75e1d4 to your computer and use it in GitHub Desktop.
Pull SCPs and content with windows
@echo off
REM Get list of SCPs in the organization
for /f "tokens=*" %%i in ('aws organizations list-policies --filter SERVICE_CONTROL_POLICY ^| jq -r ".Policies[].Id"') do (
set scp_id=%%i
REM Get SCP content
for /f "tokens=*" %%j in ('aws organizations describe-policy --policy-id !scp_id!') do (
set scp_content=%%j
)
REM Extract SCP name
for /f "tokens=*" %%k in ('echo !scp_content! ^| jq -r ".Policy.Name"') do (
set scp_name=%%k
)
REM Save SCP content into a JSON file
echo !scp_content! > "!scp_name!.json"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment