Set-ExecutionPolicy -ExecutionPolicy Bypass -Force
-
-
Save Destitute-Streetdwelling-Guttersnipe/beab1acf66a2c83d86bdea1880053dcf to your computer and use it in GitHub Desktop.
A simple scripts setups new Env Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Windows Registry Editor Version 5.00 | |
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate] | |
"TargetReleaseVersion"=dword:00000001 | |
"TargetReleaseVersionInfo"="22H2" | |
"ProductVersion"="Windows 10" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define the parent directory path | |
$parentPath = "C:\Program Files\WindowsApps" | |
# Array app remove | |
$listApps = @("Microsoft.549981C3F5F10", "Microsoft.Advertising.Xaml", "Microsoft.BingWeather", "Microsoft.Microsoft3DViewer", "Microsoft.MicrosoftOfficeHub", "Microsoft.MicrosoftSolitaireCollection", "Microsoft.MixedReality.Portal", "Microsoft.Office.OneNote", "Microsoft.People", "Microsoft.SkypeApp", "Microsoft.WindowsMaps", "Microsoft.Xbox.TCUI", "Microsoft.XboxApp", "Microsoft.XboxIdentityProvider", "Microsoft.XboxSpeechToTextOverlay", "Microsoft.XboxGamingOverlay") | |
$listAppsOptional = @("Microsoft.YourPhone", "Microsoft.WindowsCamera") | |
function Remove-Windows-Apps { | |
param ( | |
[string[]] $listAppsRemoval | |
) | |
foreach ($item in $listAppsRemoval) { | |
if ($(Get-AppxPackage $item -AllUsers).InstallLocation -like "$parentPath*" ) { | |
Get-AppxPackage $item -AllUsers | Remove-AppxPackage | |
} | |
} | |
# Get a list of child directories in the parent directory | |
$childDirectories = Get-ChildItem -Path $parentPath -Directory | |
foreach ($childDirectory in $childDirectories) { | |
$directoryName = $childDirectory.Name | |
$containsSubstring = $listAppsRemoval | Where-Object { $directoryName -like "*$_*" } | |
if ($containsSubstring) { | |
Write-Host Deleting directory $childDirectory.FullName | |
& cmd /c rmdir $childDirectory.FullName /s /q | |
} | |
} | |
} | |
Remove-Windows-Apps -listAppsRemoval $listApps | |
# Remove-Windows-Apps -listAppsRemoval $listAppsOptional | |
# rmdir /q /s "C:\Program Files\WindowsApps\DeletedAllUserPackages" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Download-UsingWebC { | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory = $true)][string]$Url, | |
[string]$Path | |
) | |
function convertFileSize { | |
param( | |
$bytes | |
) | |
if ($bytes -lt 1MB) { | |
return "$([Math]::Round($bytes / 1KB, 2)) KB" | |
} | |
elseif ($bytes -lt 1GB) { | |
return "$([Math]::Round($bytes / 1MB, 2)) MB" | |
} | |
elseif ($bytes -lt 1TB) { | |
return "$([Math]::Round($bytes / 1GB, 2)) GB" | |
} | |
} | |
Write-Verbose "URL set to ""$($Url)""." | |
if (!($Path)) { | |
Write-Verbose "Path parameter not set, parsing Url for filename." | |
$URLParser = $Url | Select-String -Pattern ".*\:\/\/.*\/(.*\.{1}\w*).*" -List | |
$Path = "./$($URLParser.Matches.Groups[1].Value)" | |
} | |
Write-Verbose "Path set to ""$($Path)""." | |
#Load in the WebClient object. | |
Write-Verbose "Loading in WebClient object." | |
try { | |
$Downloader = New-Object -TypeName System.Net.WebClient | |
} | |
catch [Exception] { | |
Write-Error $_ -ErrorAction Stop | |
} | |
#Creating a temporary file. | |
$TmpFile = New-TemporaryFile | |
Write-Verbose "TmpFile set to ""$($TmpFile)""." | |
try { | |
#Start the download by using WebClient.DownloadFileTaskAsync, since this lets us show progress on screen. | |
Write-Verbose "Starting download..." | |
$FileDownload = $Downloader.DownloadFileTaskAsync($Url, $TmpFile) | |
#Register the event from WebClient.DownloadProgressChanged to monitor download progress. | |
Write-Verbose "Registering the ""DownloadProgressChanged"" event handle from the WebClient object." | |
Register-ObjectEvent -InputObject $Downloader -EventName DownloadProgressChanged -SourceIdentifier WebClient.DownloadProgressChanged | Out-Null | |
#Wait two seconds for the registration to fully complete | |
Start-Sleep -Seconds 3 | |
if ($FileDownload.IsFaulted) { | |
Write-Verbose "An error occurred. Generating error." | |
Write-Error $FileDownload.GetAwaiter().GetResult() | |
break | |
} | |
#While the download is showing as not complete, we keep looping to get event data. | |
while (!($FileDownload.IsCompleted)) { | |
if ($FileDownload.IsFaulted) { | |
Write-Verbose "An error occurred. Generating error." | |
Write-Error $FileDownload.GetAwaiter().GetResult() | |
break | |
} | |
$EventData = Get-Event -SourceIdentifier WebClient.DownloadProgressChanged | Select-Object -ExpandProperty "SourceEventArgs" -Last 1 | |
$ReceivedData = ($EventData | Select-Object -ExpandProperty "BytesReceived") | |
$TotalToReceive = ($EventData | Select-Object -ExpandProperty "TotalBytesToReceive") | |
$TotalPercent = $EventData | Select-Object -ExpandProperty "ProgressPercentage" | |
Write-Progress -Activity "Downloading File" -Status "Percent Complete: $($TotalPercent)%" -CurrentOperation "Downloaded $(convertFileSize -bytes $ReceivedData) / $(convertFileSize -bytes $TotalToReceive)" -PercentComplete $TotalPercent | |
} | |
} | |
catch [Exception] { | |
$ErrorDetails = $_ | |
switch ($ErrorDetails.FullyQualifiedErrorId) { | |
"ArgumentNullException" { | |
Write-Error -Exception "ArgumentNullException" -ErrorId "ArgumentNullException" -Message "Either the Url or Path is null." -Category InvalidArgument -TargetObject $Downloader -ErrorAction Stop | |
} | |
"WebException" { | |
Write-Error -Exception "WebException" -ErrorId "WebException" -Message "An error occurred while downloading the resource." -Category OperationTimeout -TargetObject $Downloader -ErrorAction Stop | |
} | |
"InvalidOperationException" { | |
Write-Error -Exception "InvalidOperationException" -ErrorId "InvalidOperationException" -Message "The file at ""$($Path)"" is in use by another process." -Category WriteError -TargetObject $Path -ErrorAction Stop | |
} | |
Default { | |
Write-Error $ErrorDetails -ErrorAction Stop | |
} | |
} | |
} | |
finally { | |
#Cleanup tasks | |
Write-Verbose "Cleaning up..." | |
Write-Progress -Activity "Downloading File" -Completed | |
Unregister-Event -SourceIdentifier WebClient.DownloadProgressChanged | |
if (($FileDownload.IsCompleted) -and !($FileDownload.IsFaulted)) { | |
#If the download was finished without termination, then we move the file. | |
Write-Verbose "Moved the downloaded file to ""$($Path)""." | |
Move-Item -Path $TmpFile -Destination $Path -Force | |
} | |
else { | |
#If the download was terminated, we remove the file. | |
Write-Verbose "Cancelling the download and removing the tmp file." | |
$Downloader.CancelAsync() | |
Remove-Item -Path $TmpFile -Force | |
} | |
$Downloader.Dispose() | |
} | |
} | |
function Download-GithubReleaseLatest{ | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory = $true)][string]$Repo, | |
[string]$SampleFileName, | |
[string]$OuputFile | |
) | |
Write-Host [+] Download latest release from $Repo | |
$latestInfoJson = Invoke-Webrequest -Uri "https://api.github.com/repos/$Repo/releases/latest" -UseBasicParsing | |
$release = $latestInfoJson.Content | ConvertFrom-Json | |
$release.assets | %{ | |
if ($_.name -clike $SampleFileName){ | |
Write-Host [!] Start downloading: $_.browser_download_url | |
Download-UsingWebC -Url $_.browser_download_url -Path $OuputFile | |
} | |
} | |
} | |
# winget install --id= --scope=machine -e | |
winget install --id=RARLab.WinRAR --scope=machine -e | |
winget install --id=voidtools.Everything --scope=machine -e | |
winget install --id=Notepad++.Notepad++ --scope=machine -e | |
winget install --id=Git.Git --scope=machine -e | |
winget install --id=Microsoft.Sysinternals.ProcessExplorer --scope=machine -e | |
winget install --id=Microsoft.Sysinternals.Autoruns --scope=machine -e | |
winget install --id=Mozilla.Firefox.ESR --scope=machine -e | |
winget install --id=Brave.Brave --scope=machine -e | |
winget install --id=7zip.7zip --scope=machine -e | |
winget install --id=Mobatek.MobaXterm --scope=machine -e | |
winget install --id=Hex-Rays.IDA.Free --scope=machine -e | |
winget install --id=MHNexus.HxD --scope=machine -e | |
winget install --id=Initex.Proxifier --scope=machine -e | |
winget install --id=GlavSoft.TightVNC --scope=machine -e | |
winget install --id=ZeroTier.ZeroTierOne --scope=machine -e | |
# TimelineExplorer - https://ericzimmerman.github.io/#!index.md | |
curl -O "https://f001.backblazeb2.com/file/EricZimmermanTools/TimelineExplorer.zip" | |
# ExplorerSuite | |
curl -O "https://ntcore.com/files/ExplorerSuite.exe" | |
# Ultraview | |
curl -L -O "https://www.ultraviewer.net/en/UltraViewer_setup_6.6_en.exe" | |
# Python 3.11 | |
curl -O "https://www.python.org/ftp/python/3.11.5/python-3.11.5-amd64.exe" | |
.\python-3.11.5.exe /quiet InstallAllUsers=1 PrependPath=1 | |
# pip install mysql-connector-python | |
# VSCode Setup System | |
curl -L -o VSCode-x64.exe "https://code.visualstudio.com/sha/download?build=stable&os=win32-x64" | |
# MobaXterm keygen: https://gist.github.com/TrQ-Hoan/32f8a5a5658ba0d0b090f1a80117725f | |
curl -O "https://gist.githubusercontent.com/TrQ-Hoan/32f8a5a5658ba0d0b090f1a80117725f/raw/30e23c801aee7e49de746c31d91eaf40d1a4d660/MbXT_Keygen.py" | |
# WinRAR keygen | |
curl -L -O "https://github.com/bitcookies/winrar-keygen/releases/download/v2.1.2/winrar-keygen-x64.exe" | |
.\winrar-keygen-x64.exe "Freeware" "freeware.vn" > rarreg.key | |
# EV Key | |
curl -L -O "https://github.com/lamquangminh/EVKey/releases/download/Release/EVKey.zip" | |
# Detect it easy | |
Download-GithubReleaseLatest -Repo "horsicq/DIE-engine" -OuputFile "die_win64_portable.zip" -SampleFileName "die_win64_portable*.zip" | |
#### Windows and Office #### | |
# WSL ubuntu | |
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart | |
# ubuntu 22.04 | winget Canonical.Ubuntu.2204 | store 9PN20MSR04DW | |
wsl --set-default-version 1 | |
curl.exe -L -o ubuntu-2204.zip "https://aka.ms/wslubuntu2204" | |
# Office https://github.com/farag2/Office.git | |
Download-GithubReleaseLatest -Repo "farag2/Office" -OuputFile "Office.zip" -SampleFileName "Office*.zip" | |
powershell.exe -executionpolicy bypass "irm https://massgrave.dev/get | iex" | |
# Optimize Edge | |
# HKCU\Software\Policies\Microsoft\Edge | |
# Remove all, without ConfigureDoNotTrack | |
powershell.exe -executionpolicy bypass "irm christitus.com/win | iex" | |
# AdvanceRun | |
curl -O "https://www.nirsoft.net/utils/advancedrun-x64.zip" | |
# remove microsoft app usage AdvanceRun run with TrustedInstaller | |
powershell.exe -executionpolicy bypass .\removeapps.ps1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment