sql server: execution of Powershell code integrated in SSIS or TSQL, not in an external file

Is there a method to embed the powershell code in SSIS or T-SQL, without saving the code in an external * .ps1 file? We know that SSIS / Tsql can execute powershell, however, the code always seems to be stored elsewhere. We want the powershell code to be embedded in the SSIS package or in the stored procedure t-sql, which can then be executed.

The problem of time with Dbas, the configuration of shared file folders and then the implementation of these powershell files in our Dev, QA, Prod environments (we have several servers), can alleviate some of the processes of Devops.

1) The T-sql path can use xp_cmdshell, which can be a security problem, I'm not sure if this is true. Is there a secure way with xp_cmdshell or a totally different path in the T-SQL area?

2) The article below explains how to run Powershell in SSIS, however, it is calling another file. Can we insert code in SSIS and execute powershell?

Run PowerShell scripts in SSIS