1
1
if (! ([Security.Principal.WindowsPrincipal ][Security.Principal.WindowsIdentity ]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole ] " Administrator" )) { Start-Process powershell.exe - ArgumentList " -NoProfile" , " -ExecutionPolicy Bypass" , " -Command" , " cd `" $ ( $PWD.Path ) `" ; .\ps2exe.ps1" - Verb RunAs; exit }
2
2
3
- $nuget = Get-PackageProvider - Name " NuGet"
3
+ $workpath = $PSScriptRoot
4
+
5
+ Set-Location - Path $workpath
6
+
7
+ # Do not prompt user for confirmations
8
+ Set-Variable - Name ' ConfirmPreference' - Value ' None' - Scope Global
9
+
10
+ Install-PackageProvider NuGet - Scope AllUsers - ForceBootstrap - Confirm:$false - Force
11
+ $nuget = Get-PackageProvider - Name " NuGet" - ErrorAction SilentlyContinue
4
12
5
13
if ($nuget ) {
6
14
$psgallery = (Get-PSRepository - Name " PSGallery" ).InstallationPolicy
7
15
if ($psgallery -eq " Trusted" ) {
8
16
$ps2exe = Get-Module - Name " ps2exe"
9
17
if (! ($ps2exe )) {
10
- Install-Module ps2exe - Repository PSGallery
18
+ Install-Module ps2exe - Repository PSGallery - Scope AllUsers - SkipPublisherCheck - Force
11
19
Import-Module - Name " ps2exe" - Force
12
20
} else {
13
21
Import-Module - Name " ps2exe" - Force
14
22
}
15
23
} else {
16
24
Set-PSRepository PSGallery - InstallationPolicy Trusted
17
25
if (! ($ps2exe )) {
18
- Install-Module ps2exe - Repository PSGallery
26
+ Install-Module ps2exe - Repository PSGallery - Scope AllUsers - SkipPublisherCheck - Force
19
27
Import-Module - Name " ps2exe" - Force
20
28
} else {
21
29
Import-Module - Name " ps2exe" - Force
22
30
}
23
31
}
24
32
} else {
25
- Install-PackageProvider NuGet - Force
33
+ Install-PackageProvider NuGet - Scope AllUsers - ForceBootstrap - Confirm: $false - Force
26
34
Set-PSRepository PSGallery - InstallationPolicy Trusted
27
- Install-Module ps2exe - Repository PSGallery - Force
35
+ Install-Module ps2exe - Repository PSGallery - Force - Scope AllUsers - SkipPublisherCheck - Force
28
36
Import-Module - Name " ps2exe" - Force
29
37
}
30
38
31
39
Import-Module - Name " ps2exe" - Force
32
- ps2exe .\Nginx- Manager.ps1 .\Nginx-Manager.exe - x64 - noConsole - UNICODEEncoding - iconFile .\nginx.ico - title " Nginx Manager" - description " Nginx Manager" - product " Nginx Manager" - version 1.0 .0.0 - noOutput - exitOnCancel - DPIAware - winFormsDPIAware
40
+ ps2exe .\Nginx- Manager.ps1 .\Nginx-Manager.exe - x64 - noConsole - UNICODEEncoding - iconFile .\nginx.ico - title " Nginx Manager" - description " Nginx Manager" - product " Nginx Manager" - version 1.0 .0.0 - noOutput - exitOnCancel - DPIAware - winFormsDPIAware
0 commit comments