-
Notifications
You must be signed in to change notification settings - Fork 2
/
miiShop.ps1
43 lines (40 loc) · 1.77 KB
/
miiShop.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
#Requires -version 5.1
function check-InstallModule
{
#install modules if not installed. This way I can help setup the client with dependant modules, finally!
param($moduleName)
if([string]::IsNullOrEmpty($moduleName))
{
Write-Output 'Error: No module specified, this is an issue in the code most likely'
break;
}
if (Get-Module -ListAvailable -Name $moduleName)
{
Write-Output 'Menu Module exists, skipping install.'
}
else
{
if(-not(Install-Module -Name $moduleName -Confirm:$false -Force -ErrorAction Stop))
{
Write-Output ('Module {0} installed successfully' -f $moduleName)
}
else
{
#try to catch our errors installing
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
Write-Output 'Error Encountered'
Write-Output $ErrorMessage
Write-Output 'Failed Item'
Write-Output $FailedItem
break;
}
}
}
#Make sure we're in the right operating directory
Set-Location -path $PSScriptRoot
#the start of a launcher for miiSHop, Thanks so much
check-InstallModule PSScriptMenuGui
#check-InstallModule PoSHServer - Bye bye, PoSH server, thanks for the help...hello NGINX
Show-ScriptMenuGui -csvPath '.\main.mnu' -windowTitle 'miiShop' -iconPath '.\images\favicon.png' -buttonForegroundColor GhostWhite -buttonBackgroundColor DarkOrange -hideConsole