Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/smart-ace-designs/show-supportfiledemoform
A sample ScriptoForm. Demonstrates: how to reference an external file that is compiled into the ScriptoForm executable.
https://github.com/smart-ace-designs/show-supportfiledemoform
powershell scriptoform
Last synced: about 1 month ago
JSON representation
A sample ScriptoForm. Demonstrates: how to reference an external file that is compiled into the ScriptoForm executable.
- Host: GitHub
- URL: https://github.com/smart-ace-designs/show-supportfiledemoform
- Owner: Smart-Ace-Designs
- License: mit
- Created: 2023-05-18T01:59:18.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-04T16:33:43.000Z (about 2 months ago)
- Last Synced: 2024-11-04T17:32:02.612Z (about 2 months ago)
- Topics: powershell, scriptoform
- Language: PowerShell
- Homepage:
- Size: 42 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Show-SupportFileDemoForm
**Warning:** This ScriptoForm is for demonstration purposes only and not intended for use in a production environment.This repository contains all files required to build the **Show-SupportFileDemoForm** ScriptoForm project. A *ScriptoForm* is a PowerShell script that generates and displays a [Microsoft Windows Forms](https://learn.microsoft.com/en-us/dotnet/desktop/winforms/overview/?view=netdesktop-9.0#introduction) application that can be used for a specific management or system administration task in a network environment. A *ScriptoForm project* is the set of files and folders, including the PowerShell script, that can be compiled into an executable file using the Microsoft .NET CLI utility (dotnet.exe) which is available with any [Microsoft .NET SDK](https://dotnet.microsoft.com/en-us/download/dotnet). Included in the repository is the Build.cs C# file which the compiler will use as the source for the executable, and the Build.csproj C# project file which provides the set of instructions used to compile the executable.
## Purpose
The **Show-SupportFileDemoForm** script launches a Windows form that demonstrates using a external support file with the script that can be embedded into the compiled executable.![Screenshot 2023-05-17 212455](https://github.com/Smart-Ace-Designs/Show-SupportFileDemoForm/assets/132539186/7e711d6d-c44e-40a4-88b6-293d0f8c6cc9)
## Support Files
The following support files are included with this project:
- **Environments.txt**: Contains a list of static network environment names used for pre-populating the form at load time.Note: To ensure that support files have not be modified post extraction when the ScriptoForm has been compiled, the file hash of each file is verified before enabling functionality or displaying the form. For additional security, the PowerShell script should be signed prior to compilation and the PowerShell execution policy should be set appropriately when using the ScriptoForm.
## Requirements
- This project supports the following command shells:
- [Windows PowerShell 5.1](https://docs.microsoft.com/en-us/powershell/scripting/overview?view=powershell-5.1)
- [PowerShell 7.4.x](https://docs.microsoft.com/en-us/powershell/scripting/overview?view=powershell-7.4)
- [PowerShell 7.5.x](https://docs.microsoft.com/en-us/powershell/scripting/overview?view=powershell-7.5)
- This project supports the following Microsoft .NET frameworks:
- [Microsoft .NET 4.x](https://dotnet.microsoft.com/en-us/download/dotnet-framework)
- [Microsoft .NET 8.x](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)
- [Microsoft .NET 9.x](https://dotnet.microsoft.com/en-us/download/dotnet/9.0)## Compile Instructions
Perform the following prerequisite steps:
- Install the [Microsoft .NET 9.x SDK](https://dotnet.microsoft.com/en-us/download/dotnet/9.0) on your development machine.
- Clone the repository to your development machine.Use any of the below workflows to create an executable file of the PowerShell script that is compatible with the framework version specified:
Microsoft .NET 4.x Framework
- Open a supported command shell and navigate to the *Build* subdirectory in your local repository directory.
- Run the following command from within your *Build* subdirectory:
``dotnet publish -f net48 -v q -nologo -o ..\Release\Legacy; dotnet clean -f net48 -v q -nologo``
- The compiled executable will be created in the *Release\Legacy* subdirectory of your local repository directory. This location can be changed by modifying the ``-o`` argument in the above command.
- The latest [Microsoft .NET 4.x Framework Runtime](https://dotnet.microsoft.com/en-us/download/dotnet-framework/net48) will be required on any computer used to run the executable.Microsoft .NET 8.x Framework
- Open a supported command shell and navigate to the *Build* subdirectory in your local repository directory.
- Run the following command from within your *Build* subdirectory:
``dotnet publish -f net8.0-windows -v q -nologo -o ..\Release\LTS; dotnet clean -f net8.0-windows -v q -nologo``
- The compiled executable will be created in the *Release\LTS* subdirectory of your local repository directory. This location can be changed by modifying the ``-o`` argument in the above command.
- The latest [Microsoft .NET 8.x Runtime](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) will be required on any computer used to run the executable.Microsoft .NET 9.x Framework
- Open a supported command shell and navigate to the *Build* subdirectory in your local repository directory.
- Run the following command from within your *Build* subdirectory:
``dotnet publish -f net9.0-windows -v q -nologo -o ..\Release\LTS-Legacy; dotnet clean -f net9.0-windows -v q -nologo``
- The compiled executable will be created in the *Release\LTS-Legacy* subdirectory of your local repository directory. This location can be changed by modifying the ``-o`` argument in the above command.
- The latest [Microsoft .NET 9.x Runtime](https://dotnet.microsoft.com/en-us/download/dotnet/9.0) will be required on any computer used to run the executable.## Executable Notes
- When the executable file is run it will extract all resource files that were included in the compilation process to a unique temporary extraction directory in the user's profile directory.
- The executable will attempt to use the latest version of PowerShell discovered on the local machine to execute the extracted script file unless excluded by one of the command-line arguments noted below. If a version of PowerShell is excluded by a command-line argument then the executable will attempt to use the next latest version of PowerShell discovered on the system. The executable will always default to using Windows PowerShell if no other versions are available for use.
- After the PowerShell script execution has completed, all extracted files and the extraction directory are deleted and the executable terminates.
- The following optional command-line arguments can be used to control operation of the executable:
| Argument | Purpose | Notes |
| ------------ | --------------------------------- | ---------------------------------------------- |
| -exclude:all | Exclude PowerShell x.x.x versions | Do not use with other *exclude* arguments |
| -exclude:ps7 | Exclude PowerShell 7.x.x versions | Do not use with other *exclude* arguments |
| -debug | Show console window | Use individually or with an *exclude* argument |