Skip to content

A sample ScriptoForm used to schedule a onetime restart of a remote server. Demonstrates: using a datetimepicker control and textbox validation.

License

Notifications You must be signed in to change notification settings

Smart-Ace-Designs/New-ServerRestart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

New-ServerRestart

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 New-ServerRestart ScriptoForm project. A ScriptoForm is a PowerShell script that generates and displays a Microsoft Windows Forms 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. 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 New-ServerRestart script launches a Windows form that provides a method to schedule a one time restart on a remote server.

Screenshot 2023-05-17 211734

Requirements

Compile Instructions

Perform the following prerequisite steps:

  • Install the Microsoft .NET 8.x SDK 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 parameter in the above command.
  • The latest Microsoft .NET 4.x Framework Runtime will be required on any computer used to run the executable.

Microsoft .NET 6.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 net6.0-windows -v q -nologo -o ..\Release\LTS-Legacy; dotnet clean -f net6.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 parameter in the above command.
  • The latest Microsoft .NET 6.x Runtime 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 parameter in the above command.
  • The latest Microsoft .NET 8.x Runtime 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 parameters
    -Exclude:PS7 Exclude PowerShell 7.x.x versions Do not use with other Exclude parameters
    -Debug Show console window Use individually or with one additional Exclude parameter

About

A sample ScriptoForm used to schedule a onetime restart of a remote server. Demonstrates: using a datetimepicker control and textbox validation.

Topics

Resources

License

Stars

Watchers

Forks