Issue
I'm trying to create a basic GUI for PowerShell, but for some reason it can't recognize the Add-Type parameter. this is the code I've used:
# Init PowerShell Gui
Add-Type -AssemblyName System.Windows.Forms
# Create a new form
$LocalPrinterForm = New-Object system.Windows.Forms.Form
# Define the size, title and background color
$LocalPrinterForm.ClientSize = '500,300'
$LocalPrinterForm.text = "LazyAdmin - PowerShell GUI Example"
$LocalPrinterForm.BackColor = "#ffffff"
# Display the form
[void]$LocalPrinterForm.ShowDialog()
when running it with: $ ./exampleScript.ps1
I get: ./exampleScript.ps1: line 2: Add-Type: command not found
what can be the problem here?
Solution
The add-type command is working fine with me I have version 5.1.18362.628
to find your PowerShell version type the following command:
$PSVersionTable
Answered By - mohamed saeed