So I'm looking for a way to convert .ps1 scripts(using an online tool or whatever that works) to string format so that I can just copy and paste it into my C# code in a string variable.
This will enable me to stop referencing the paths of my scripts in the code as these may change from one computer/user to another.
Thanks !
CodePudding user response:
base64 encode and decode
I would use this solution: https://www.base64encode.org/ You can also test the string... with the decode link: https://www.base64decode.org/
I am sure in C# you have also base64decode to reconvert into PS1.
CodePudding user response:
its not exactly what you want but let point you how we realy work in IT domain.
you have to use environement variable that will point to script folder on any
Machine/user.
https://docs.microsoft.com/en-us/windows/deployment/usmt/usmt-recognized-environment-variables
here you can get exemple how to use it with c#
