how to script out proxy accounts?
DBATools has a convenient command Copy-DbaAgentProxy in its PoSh module that I highly recommend.

By default, all proxy accounts are copied. The -ProxyAccounts parameter is auto-populated for command-line completion and can be used to copy only specific proxy accounts.
If the associated credential for the account does not exist on the destination, it will be skipped. If the proxy account already exists on the destination, it will be skipped unless -Force is used.

Or, to generate the files, you can also use Get-DbaAgentProxy and Export-DbaScript.