Skip to content

Instantly share code, notes, and snippets.

@dumpvn
Last active March 6, 2022 16:05
Show Gist options
  • Save dumpvn/d31d744ec3396722f779d0d62c5a514c to your computer and use it in GitHub Desktop.
Save dumpvn/d31d744ec3396722f779d0d62c5a514c to your computer and use it in GitHub Desktop.
quick-download.ps1
set-location $psscriptroot
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Confirm
Install-Module -Name PackageManagement -Force -MinimumVersion 1.4.6 -Scope CurrentUser -AllowClobber -Repository PSGallery
# repos_home
if (-not (get-module xNetworking -ListAvailable)) {
Find-Module xNetworking | Install-Module -SkipPublisherCheck
}
if (-not (get-module xWebAdministration -ListAvailable)) {
Find-Module xWebAdministration | Install-Module -SkipPublisherCheck
}
if (-not (get-module ComputerManagementDsc -ListAvailable)) {
Find-Module ComputerManagementDsc | Install-Module -SkipPublisherCheck
}
if (-not (get-module xPSDesiredStateConfiguration -ListAvailable)) {
Find-Module xPSDesiredStateConfiguration | Install-Module -SkipPublisherCheck
}
if (-not (get-module xSmbShare -ListAvailable)) {
Find-Module xSmbShare | Install-Module -SkipPublisherCheck
}
if (-not (get-module PoShKeePass -ListAvailable)) {
Find-Module PoShKeePass | Install-Module -SkipPublisherCheck
}
Configuration QuickDownload {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$Path
)
# Import-DscResource -Name MSFT_xSmbShare
# Import-DscResource -ModuleName xNetworking
Import-DscResource -ModuleName PsDesiredStateConfiguration
Import-DscResource -ModuleName xPSDesiredStateConfiguration
Node 'localhost' {
File README {
DestinationPath = 'C:\Software\README.txt'
Ensure = "Present"
Contents = "Deployed Date: $(Get-Date)"
}
File PowershellProfile {
DestinationPath = $profile
Ensure = "Present"
Contents = "if (test-path '$(Join-Path $psscriptroot 'dumpvn\text\powershell-profile.ps1')') {. $(Join-Path $psscriptroot 'dumpvn\text\powershell-profile.ps1')}"
}
<# HTTP request with TLS v1.2 #>
Registry SchUseStrongCrypto
{
Key = 'HKLM:\SOFTWARE\Microsoft\.NETFramework\v4.0.30319'
ValueName = 'SchUseStrongCrypto'
ValueType = 'Dword'
ValueData = '1'
Ensure = 'Present'
}
Registry SchUseStrongCrypto64
{
Key = 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319'
ValueName = 'SchUseStrongCrypto'
ValueType = 'Dword'
ValueData = '1'
Ensure = 'Present'
}
<# The xRemoteFile resource from xPSDesiredStateConfiguration DSC module used to download an MSI through HTTP #>
xRemoteFile DownloadKeePass {
Uri = "https://onboardcloud.dl.sourceforge.net/project/keepass/KeePass%202.x/2.50/KeePass-2.50.zip"
DestinationPath = 'C:\Software\KeePass-2.50.zip'
UserAgent = [Microsoft.PowerShell.Commands.PSUserAgent]::InternetExplorer
Headers = @{
'Accept-Language' = 'en-US'
}
DependsOn = @('[Registry]SchUseStrongCrypto','[Registry]SchUseStrongCrypto64')
}
Archive UnzipKeePassZip
{
Destination = (Join-Path $env:LOCALAPPDATA 'KeePass')
Path = 'C:\Software\KeePass-2.50.zip'
Ensure = 'Present'
DependsOn = '[xRemoteFile]DownloadKeePass'
}
xRemoteFile Downloadfilelocator2951 {
Uri = "https://download.mythicsoft.com/flp/2951/filelocator_2951.exe"
DestinationPath = 'C:\Software\filelocator_2951.exe'
UserAgent = [Microsoft.PowerShell.Commands.PSUserAgent]::InternetExplorer
Headers = @{
'Accept-Language' = 'en-US'
}
DependsOn = @('[Registry]SchUseStrongCrypto','[Registry]SchUseStrongCrypto64')
}
Package InstallFileLocatorPro
{
Ensure = "Present"
Name = 'FileLocator'
ProductId = 'CE59CD53-AE56-48B6-B99F-EFE9F7A1CFE9'
Path = 'C:\Software\filelocator_2951.exe'
DependsOn = @('[xRemoteFile]Downloadfilelocator2951')
}
xRemoteFile DownloadGit235 {
Uri = "https://github.com/git-for-windows/git/releases/download/v2.35.1.windows.2/Git-2.35.1.2-64-bit.exe"
DestinationPath = 'C:\Software\Git-2.35.1.2-64-bit.exe'
UserAgent = [Microsoft.PowerShell.Commands.PSUserAgent]::InternetExplorer
Headers = @{
'Accept-Language' = 'en-US'
}
DependsOn = @('[Registry]SchUseStrongCrypto','[Registry]SchUseStrongCrypto64')
}
xRemoteFile DownloadVsCode {
Uri = "https://code.visualstudio.com/sha/download?build=stable&os=win32-x64-user"
DestinationPath = 'C:\Software\VSCodeUserSetup-x64.exe'
UserAgent = [Microsoft.PowerShell.Commands.PSUserAgent]::InternetExplorer
Headers = @{
'Accept-Language' = 'en-US'
}
DependsOn = @('[Registry]SchUseStrongCrypto','[Registry]SchUseStrongCrypto64')
}
xRemoteFile DownloadSetupScript {
Uri = "https://gist.githubusercontent.com/dumpvn/787d6f5ffc43084f09db15c9cb68a602/raw/c83debb07f4ac9964db47b17e6618e3949c2a890/setup-new-pc.ps1"
DestinationPath = (Join-Path $psscriptroot 'setup-script.ps1')
UserAgent = [Microsoft.PowerShell.Commands.PSUserAgent]::InternetExplorer
Headers = @{
'Accept-Language' = 'en-US'
}
DependsOn = @('[Registry]SchUseStrongCrypto','[Registry]SchUseStrongCrypto64')
}
Environment EnvReposHome
{
Name = 'REPOS_HOME'
Path = $false
Value = $psscriptroot
Ensure = 'Present'
}
}
}
$cd = @{
AllNodes = @(
@{
NodeName = "*"
PSDscAllowPlainTextPassword = $true
}
)
}
QuickDownload -ConfigurationData $cd -Path 'C:\Users\HP\Desktop\__TMP__'
Start-DscConfiguration -Path .\QuickDownload -Wait -Force -Verbose
remove-item .\QuickDownload -Force -recurse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment