Created
May 10, 2024 14:06
-
-
Save houey/ab0175831fdba7e8371e8bc32e75e1d4 to your computer and use it in GitHub Desktop.
Pull SCPs and content with windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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