I have figured out I could associate an existing application pool with an existing site like this:
APPCMD.exe set app "sitename/" /applicationPool:"appPoolName"
But how do I create my own application pool with the name appPoolName, .NET version 4 and Integrated pipeline prior to this command?
This:
should give you everything you need. In particular
appcmd add apppool /name:appPoolName /managedRuntimeVersion:"v4.0" /managedPipelineMode:"Integrated"
should do the job.