1st time poster, so sorry if this is incorrect
Im an IT SysAdmin/general I.T Admin
Background: I have created some separate powershell scripts to do some basic repetitive tasks, this could be adding firewall rules, renaming computers, creating Local accounts on a PC. In order to bypass the powershell script execution policy on computers, I have a .bat and a ps1 file. I launch the relevant .bat, which in turn launches the ps1 file that does the work. These work fine for myself since I know how they work and I dont mind working with the powershell console etc but is a bit of a pain copying the required .bat/ps1 files to a computer, executing and then deleting the files before shipping to a customer
End Goal:
- Eliminate the need for multiple .bat/.ps1's having to be copied to a PC and run each script individually
- Eliminate powershell console view for user input etc
- Try to get just 1 .exe (with all my scripts embedded within) that I can give to other members of the team that essentially does the same as the powershell scripts but just looks nicer
My thoughts are: Create a c# program (ive never used c# before) but if I can learn just enough to create a program with some buttons that you press that launches my specific powershell scripts.
- Low level - A basic Form, buttons that launch a hardcoded powershell script (essentially copy.paste my script into the button code)
- high level - A nice GUI with buttons that launch powershell scripts from the Internet or separate embedded resources within the .exe and if needed to prompt for user input, it prompts within the Nice GUI and then passes this back to the script?
What I know so far?
Ive seen some links such as: https://blogs.msdn.microsoft.com/kebab/2014/04/28/executing-powershell-scripts-from-c/ I can hardcode the individual scripts code into each button I guess? but then if my scripts change as im testing/improving I would need to keep rebuilding the .exe and changing each button
Can you embed within the .exe a .ps1 resource or something? so I can hardcode ".\Script1.ps" on the button launch? rather than D:\Temp\Script.ps1..I understand I would still need to compile the .exe each time but at least it would be a bit tidier
Ive tried searching on here and googling but I havent exactly found what im looking for. Is this best practice? I seen on the internet people saying powershell can do what C# does and vice versa...the reason i would want to do it this way is I already have the powershell scripts created and the c# aspect of it is just for me to get a nice GUI keeping everything together hopefully
Thanks a lot for your help and if this question is too long/messy that I apologize