-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpowershell-designer.psm1
76 lines (69 loc) · 4.18 KB
/
powershell-designer.psm1
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
function powershell-designer($a) {
function path($a) {
return Split-Path -Path $a
}
function chr($a) {
$a = $a | Out-String
return [char][byte]$a
}
$folderExists = Test-Path -path ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\functions")
if ($folderExists -eq $false){
New-Item -ItemType directory -Path ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\functions")
}
$functionsExists = Test-Path -path ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\functions\functions.psm1")
if ($functionsExists -eq $false){
Copy-Item -Path "$PSScriptRoot\functions\functions.psm1" -destination ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\functions\functions.psm1")
}
$dependenciesExists = Test-Path -path ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\functions\Dependencies.ps1")
if ($dependenciesExists -eq $false){
Copy-Item -Path "$PSScriptRoot\functions\Dependencies.ps1" -destination ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\functions\Dependencies.ps1")
}
$designerExists = Test-Path -path ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\designer\designer.ps1")
if ($designerExists -eq $false){
New-Item -ItemType directory -Path ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\Designer")
Copy-Item -Path "$PSScriptRoot\Designer.fbs" -destination ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer")
Copy-Item -Path "$PSScriptRoot\Designer\Designer.ps1" -destination ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\Designer")
Copy-Item -Path "$PSScriptRoot\Designer\Events.ps1" -destination ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\Designer")
Copy-Item -Path "$PSScriptRoot\Designer\finds.txt" -destination ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\Designer")
}
$ExamplesExists = Test-Path -path ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\Examples")
if ($ExamplesExists -eq $false){
Copy-Item -Path "$PSScriptRoot\Examples" -destination ([Environment]::GetFolderPath("MyDocuments")+"\PowerShell Designer\Examples") -recurse
}
if ($a) {
if ((get-host).version.major -eq 7) {
if ((Get-Module -ListAvailable powershell-designer).count -gt 1){
start-process -filepath pwsh.exe -argumentlist '-ep bypass',"-file $(chr 34)$(path $(Get-Module -ListAvailable PowerShell-Designer)[0].path)\Designer\Designer.ps1$(chr 34)","$($a)"
}
else {
start-process -filepath pwsh.exe -argumentlist '-ep bypass',"-file $(chr 34)$(path $(Get-Module -ListAvailable PowerShell-Designer).path)\Designer\Designer.ps1$(chr 34)","$($a)"
}
}
else {
if ((Get-Module -ListAvailable powershell-designer).count -gt 1){
start-process -filepath powershell.exe -argumentlist '-ep bypass',"-file $(chr 34)$(path $(Get-Module -ListAvailable PowerShell-Designer)[0].path)\Designer\Designer.ps1$(chr 34)","$($a)"
}
else {
start-process -filepath powershell.exe -argumentlist '-ep bypass',"-file $(chr 34)$(path $(Get-Module -ListAvailable PowerShell-Designer).path)\Designer\Designer.ps1$(chr 34)","$($a)"
}
}
}
else{
if ((get-host).version.major -eq 7) {
if ((Get-Module -ListAvailable powershell-designer).count -gt 1){
start-process -filepath pwsh.exe -argumentlist '-ep bypass',"-file $(chr 34)$(path $(Get-Module -ListAvailable PowerShell-Designer)[0].path)\Designer\Designer.ps1$(chr 34)"
}
else {
start-process -filepath pwsh.exe -argumentlist '-ep bypass',"-file $(chr 34)$(path $(Get-Module -ListAvailable PowerShell-Designer).path)\Designer\Designer.ps1$(chr 34)"
}
}
else {
if ((Get-Module -ListAvailable powershell-designer).count -gt 1){
start-process -filepath powershell.exe -argumentlist '-ep bypass',"-file $(chr 34)$(path $(Get-Module -ListAvailable PowerShell-Designer)[0].path)\Designer\Designer.ps1$(chr 34)"
}
else {
start-process -filepath powershell.exe -argumentlist '-ep bypass',"-file $(chr 34)$(path $(Get-Module -ListAvailable PowerShell-Designer).path)\Designer\Designer.ps1$(chr 34)"
}
}
}
}