Portal for ArcGIS exposes its functionality through the ArcGIS REST API, therefore you can script the administration of the portal using the API. The sample scripts included with Portal for ArcGIS leverage this API and have been written so you can run them easily from any machine configured with the Python 2.7 environment (required). The scripts are designed to be executed as is from the command line. However, you can customize them, create your own, or use them to learn how to interact with the REST API.
The following samples are available: