Powershell direct on jenkins or through Powershell file

Hi All.

Newbie here my first post.

I am working on an automation project which uses powershell, I have the powershell plugin setup and at the moment can run commands direct on jenkins.

We do have plans to integrate our code into a repository system, so the idea is that jenkins will pull this down and run the code.

I have the following questions.

Is it better for me to leave my PS code in a powershell file and run this in Jenkins or copy the content onto jenkins and run it direct. One factor here is that nt codd uses windows removing extensively and one of the positives with putting the code direct on jenkins is the ability to use parameter variables and pass credentials that way. If I use a file, I wound need to pass the credentials to the file so that windows removing can use it.

Second question is how can I pass values which are often output from the code or ps script file within build steps in jenkins ?