-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBootstrap.ps1
More file actions
28 lines (23 loc) · 1.25 KB
/
Bootstrap.ps1
File metadata and controls
28 lines (23 loc) · 1.25 KB
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
#Bootstrap.ps1
# function to test if the script is running as admin
if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Warning "You do not have Administrator rights to run this script!`nPlease re-run this script as an Administrator!"
$arguments = "-command irm PSToolbox.cloudfactory.dk | iex"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
$Rootfolder = "C:\CloudFactoryToolbox"
$scriptPath = join-path -Path $Rootfolder -ChildPath "Main.ps1"
#create rootfolder if it doesnt exist
if (!(Test-Path $Rootfolder)) {
New-Item -ItemType Directory -Path $Rootfolder | Out-Null
}
Invoke-RestMethod "https://raw.githubusercontent.com/cloudfactorydk/PSToolbox/main/Main.ps1" | Out-File -Encoding utf8 -FilePath $scriptPath -Force
# start script elevated
$arguments="-NoExit -file $scriptPath -executionpolicy bypass"
if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Start-Process powershell -runAs -ArgumentList $arguments
}
else {
Start-Process powershell -ArgumentList $arguments
}