# Generate a Tool from a Function

Using the `PowerShell Pro Tools: Generate Tool` command you can generate a WinForm and then compile it into an executable in one step. It uses the same concept as the Generate a UI from a function and the PoshTools packager to create the tool.

Press `Ctrl+Shift+P` to open the command pallete and search for the command. You will need to have a PS1 file open with a single function in it that defines the parameters for the tool you'd like to create.&#x20;

For example, you could have a new user function like this.&#x20;

```
function New-User {
    param([String]$UserName, [Switch]$Enabled, [ValidateSet("Administrator", "IT", "HR")]$Department)
}
```

This would generate a form that looked like this.&#x20;

![Auto-generated UI](https://3667946160-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LNFE66tpE_51uobNA70%2F-LcECu6gw9p573fdATUJ%2F-LcED17lLKG6vj4A1kda%2Fimage.png?alt=media\&token=a4291d1e-054e-4229-9c3a-2d5b7ca6878f)

If the file was named `NewUser.ps1` , then a `NewUser.exe` would be created that would show the form and execute your tool.&#x20;
