Reputation: 69
I have a Win Form App (C#) which buttons call powershell script. If I share this app (exe file) I also need to attach all ps1 file with it. For security reason, I wanted to make sure user unable to open ps1 files and read scripts. Is it possible to make them secured?
To elaborate more, I would like to restrict read access to all scripts only. As an app user, user should just simply click buttons to see the results. User should not be able to open script files to see details code. So a user should just click windowsApp.exe and run the Windows Form app. Once click the button it should run ps script. All I am looking into to see if .net can somehow hide all ps1 files from end users visibility.
Thanks in advance for your help!!
Upvotes: 1
Views: 199
Reputation: 42
Hiding credentials is difficult, if not impossible, to pull off with 100% certainty. It is best practice to prompt for credentials then use them in another cmdlet. For example:
$credential = Get-Credential
Enter-PSSession -ComputerName SERVER01 -Credential $credential
If you hardcode your credentials into the script, you not only open up your password(s) to the users but also can run into issues if your password changes. AD lockouts caused by something like this are a pain to track down.
What exactly are you trying to do? There may be a way to satisfy your requirements if you could be more specific.
Upvotes: 1