-
Notifications
You must be signed in to change notification settings - Fork 1
/
get.ps1
54 lines (45 loc) · 2.34 KB
/
get.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
44
45
46
47
48
49
50
51
52
53
54
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Start-Process powershell -Verb runAs -ArgumentList "Invoke-RestMethod https://noahzeisberg.github.io/FyUTILS/get.ps1 | Invoke-Expression"
Exit
}
Write-Output "Starting FyUTILS installation..."
Write-Output "Setting up variables..."
$fileName = "FyUTILS.exe"
$folderPath = Join-Path $env:USERPROFILE ".fy"
$filePath = Join-Path $folderPath $fileName
$githubApiUrl = "https://api.github.com/repos/noahzeisberg/FyUTILS/releases/latest"
Write-Output "Creating local file..."
New-Item -ItemType Directory -Path $folderPath -Force | Out-Null
Write-Output "Fetching API information..."
$releaseInfo = Invoke-RestMethod -Uri $githubApiUrl
Write-Output "Processing data..."
$fileDownloadUrl = $releaseInfo.assets | Where-Object { $_.name -eq $fileName } | Select-Object -ExpandProperty browser_download_url
Write-Output "Downloading file from GitHub..."
Invoke-WebRequest -Uri $fileDownloadUrl -OutFile $filePath
Write-Output "Checking for environment variable..."
if (-not ($folderPath -in $env:Path)) {
Write-Output "Backing up PATH to C:\PATHBACKUP.TXT..."
Out-File -FilePath "C:\PATHBACKUP.TXT" -InputObject $env:Path -Force -Encoding utf8
Write-Output "Adding directory to your environment variables..."
[Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + $folderPath, "Machine")
}
Write-Output "Excluding FyUTILS directory from Windows Defender..."
if (Get-Command -ErrorAction SilentlyContinue Get-MpPreference) {
$existingExclusions = Get-MpPreference | Select-Object -ExpandProperty ExclusionPath
if ($existingExclusions -contains $folderPath) {
Write-Output "Exclusion for $folderPath already exists. No changes made."
}
else {
$existingExclusions += $folderPath
Set-MpPreference -ExclusionPath $existingExclusions
Write-Output "Exclusion for $folderPath added successfully."
}
}
else {
Write-Warning "Windows Defender is not installed or not available on this system."
}
Write-Output " "
Write-Output "Installation of FyUTILS complete! Please consider starring this repository."
Write-Output "https://github.com/noahzeisberg/FyUTILS"
Write-Output " "
Start-Process wt.exe fyutils.exe