temp!
This commit is contained in:
parent
2e60d0c414
commit
9bc55000a3
@ -9,79 +9,62 @@ if (-Not $is_elevated) {
|
|||||||
Invoke-WebRequest -Uri https://get.scoop.sh -OutFile $scoop_installer
|
Invoke-WebRequest -Uri https://get.scoop.sh -OutFile $scoop_installer
|
||||||
&$scoop_installer -ScoopDir "$env:LocalAppData/Scoop" -ScoopGlobalDir "$env:ProgramData/Scoop"
|
&$scoop_installer -ScoopDir "$env:LocalAppData/Scoop" -ScoopGlobalDir "$env:ProgramData/Scoop"
|
||||||
|
|
||||||
# Get the current script's path
|
Start-Process $ps -Verb runas -ArgumentList "& '$script'"
|
||||||
$ScriptPath = $MyInvocation.MyCommand.Definition
|
|
||||||
|
|
||||||
# Create a new process to run the script as administrator
|
|
||||||
$StartInfo = New-Object System.Diagnostics.ProcessStartInfo
|
|
||||||
$StartInfo.FileName = "powershell.exe"
|
|
||||||
|
|
||||||
# Add parameters to the command-line arguments
|
|
||||||
$StartInfo.Arguments = "-NoProfile -ExecutionPolicy Bypass -File `"$ScriptPath`""
|
|
||||||
|
|
||||||
# Elevate privileges
|
|
||||||
$StartInfo.Verb = "runas"
|
|
||||||
|
|
||||||
# Ensure output is visible to the user
|
|
||||||
$StartInfo.UseShellExecute = $true
|
|
||||||
$StartInfo.RedirectStandardOutput = $false
|
|
||||||
$StartInfo.RedirectStandardError = $false
|
|
||||||
$StartInfo.CreateNoWindow = $false
|
|
||||||
|
|
||||||
# Start the elevated process
|
|
||||||
[System.Diagnostics.Process]::Start($StartInfo) | Out-Null
|
|
||||||
|
|
||||||
# Exit the current (non-admin) process
|
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
# Running with elevated permissions
|
# Code to execute after elevation
|
||||||
|
Write-Host "Running as Administrator. Performing privileged actions..."
|
||||||
|
|
||||||
# Install 1Password
|
# Pause the script so you can see any output
|
||||||
$decision = $Host.UI.PromptForChoice('Install 1Password', 'Proceed?', $choices, 0)
|
Write-Host "Press Enter to exit..."
|
||||||
if ($decision -eq 0) {
|
Start-Sleep -Seconds 3600 # Sleep for an hour, effectively pausing the script
|
||||||
$1password_installer = "$env:USERPROFILE/Downloads/1PasswordSetup-latest.exe"
|
|
||||||
Invoke-WebRequest -Uri "https://downloads.1password.com/win/1PasswordSetup-latest.exe" -OutFile "$1password_installer"
|
|
||||||
&$1password_installer
|
|
||||||
Remove-Item $1password_installer
|
|
||||||
} else {
|
|
||||||
echo 'Skipping 1Password'
|
|
||||||
}
|
|
||||||
|
|
||||||
# Enable Hyper-V
|
# # Install 1Password
|
||||||
$decision = $Host.UI.PromptForChoice('Enable Hyper-V', 'Proceed?', $choices, 0)
|
# $decision = $Host.UI.PromptForChoice('Install 1Password', 'Proceed?', $choices, 0)
|
||||||
if ($decision -eq 0) {
|
# if ($decision -eq 0) {
|
||||||
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
|
# $1password_installer = "$env:USERPROFILE/Downloads/1PasswordSetup-latest.exe"
|
||||||
} else {
|
# Invoke-WebRequest -Uri "https://downloads.1password.com/win/1PasswordSetup-latest.exe" -OutFile "$1password_installer"
|
||||||
echo 'Skipping Hyper-V'
|
# &$1password_installer
|
||||||
}
|
# Remove-Item $1password_installer
|
||||||
|
# } else {
|
||||||
|
# echo 'Skipping 1Password'
|
||||||
|
# }
|
||||||
|
|
||||||
# Enable Containters
|
# # Enable Hyper-V
|
||||||
$decision = $Host.UI.PromptForChoice('Enable Containers', 'Proceed?', $choices, 0)
|
# $decision = $Host.UI.PromptForChoice('Enable Hyper-V', 'Proceed?', $choices, 0)
|
||||||
if ($decision -eq 0) {
|
# if ($decision -eq 0) {
|
||||||
Enable-WindowsOptionalFeature -Online -FeatureName Containers -All
|
# Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
|
||||||
} else {
|
# } else {
|
||||||
echo 'Skipping Containers'
|
# echo 'Skipping Hyper-V'
|
||||||
}
|
# }
|
||||||
|
|
||||||
# Get the shell application object
|
# # Enable Containters
|
||||||
$shellApp = New-Object -ComObject "Shell.Application"
|
# $decision = $Host.UI.PromptForChoice('Enable Containers', 'Proceed?', $choices, 0)
|
||||||
|
# if ($decision -eq 0) {
|
||||||
|
# Enable-WindowsOptionalFeature -Online -FeatureName Containers -All
|
||||||
|
# } else {
|
||||||
|
# echo 'Skipping Containers'
|
||||||
|
# }
|
||||||
|
|
||||||
# Run the command without elevation
|
# # Get the shell application object
|
||||||
$shellApp.ShellExecute("powershell.exe", "-NoProfile -Command `"& { $nonElevatedCommand }`"", "", "open", 0)
|
# $shellApp = New-Object -ComObject "Shell.Application"
|
||||||
|
|
||||||
# Start-Process -NoNewWindow -Credential "$env:UserDomain\$env:UserName" -FilePath "powershell.exe" -ArgumentList "-NoProfile -Command & { & $($command) }"
|
# # Run the command without elevation
|
||||||
# Start-Process -FilePath "powershell.exe" -ArgumentList "-NoProfile -Command & { & $($command) }" -Credential $user -WindowStyle Hidden
|
# $shellApp.ShellExecute("powershell.exe", "-NoProfile -Command `"& { $nonElevatedCommand }`"", "", "open", 0)
|
||||||
|
|
||||||
# Install Chocolatey
|
# # Start-Process -NoNewWindow -Credential "$env:UserDomain\$env:UserName" -FilePath "powershell.exe" -ArgumentList "-NoProfile -Command & { & $($command) }"
|
||||||
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
|
# # Start-Process -FilePath "powershell.exe" -ArgumentList "-NoProfile -Command & { & $($command) }" -Credential $user -WindowStyle Hidden
|
||||||
|
|
||||||
# Install SSH Server
|
# # Install Chocolatey
|
||||||
$decision = $Host.UI.PromptForChoice('Install SSH Server', 'Proceed?', $choices, 0)
|
# iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
|
||||||
if ($decision -eq 0) {
|
|
||||||
choco install --yes "--package-parameters=/SSHServerFeature" openssh
|
# # Install SSH Server
|
||||||
Start-Service sshd
|
# $decision = $Host.UI.PromptForChoice('Install SSH Server', 'Proceed?', $choices, 0)
|
||||||
Set-Service -Name sshd -StartupType 'Automatic'
|
# if ($decision -eq 0) {
|
||||||
} else {
|
# choco install --yes "--package-parameters=/SSHServerFeature" openssh
|
||||||
echo 'Skipping SSH Server'
|
# Start-Service sshd
|
||||||
}
|
# Set-Service -Name sshd -StartupType 'Automatic'
|
||||||
|
# } else {
|
||||||
|
# echo 'Skipping SSH Server'
|
||||||
|
# }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user