Last active
January 4, 2024 19:09
-
-
Save kilasuit/4e214e5add0169ada3cde9ca24163b5b to your computer and use it in GitHub Desktop.
Simple BootStrap for new machines
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
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force -Scope LocalMachine | |
function Enable-PSTranscription { | |
$basePath = "HKLM:\Software\Policies\Microsoft\Windows\PowerShell\Transcription" | |
if (-not (Test-Path $basePath)) { $null = New-Item $basePath –Force } | |
Set-ItemProperty $basePath -Name EnableTranscripting -Value 1 | |
Set-ItemProperty $basePath -Name OutputDirectory -Value "$env:USERPROFILE\OneDrive\PSTranscripts\$env:COMPUTERNAME\" | |
Set-ItemProperty $basePath -Name EnableInvocationHeader -Value 1 | |
$basePath = "HKLM:\Software\Policies\Microsoft\PowerShellCore\Transcription" | |
if(-not (Test-Path $basePath)) { $null = New-Item $basePath -Force } | |
Set-ItemProperty $basePath -Name EnableTranscripting -Value 1 | |
Set-ItemProperty $basePath -Name OutputDirectory -Value "$env:USERPROFILE\OneDrive\PSTranscripts\$env:COMPUTERNAME\PSCore\" | |
Set-ItemProperty $basePath -Name EnableInvocationHeader -Value 1 | |
} | |
Enable-PSTranscription | |
# Install PowerShell Preview via Windows Update (from no prior install) | |
$pwshRegPath = "HKLM:\SOFTWARE\Microsoft\PowerShellCore" | |
$previewPath = Join-Path -Path $pwshRegPath -ChildPath "InstalledVersions\39243d76-adaf-42b1-94fb-16ecf83237c8" | |
if (!(Test-Path -Path $previewPath)) { | |
$null = New-Item -Path $previewPath -ItemType Directory -Force | |
} | |
Set-ItemProperty -Path $pwshRegPath -Name UseMU -Value 1 -Type DWord | |
Set-ItemProperty -Path $previewPath -Name Install -Value 1 -Type DWord | |
# Forces BootStrap of Package Provider for Chocolatey on an System with PowerShell v5 or the PackageManagement Modules installed | |
Install-Module -Name Chocolatey -Force -Verbose -Confirm:$false | |
Start-Sleep 10 | |
Install-ChocolateySoftware -Verbose -InformationAction Continue | |
Install-ChocolateyPackage git,vscode,vscode-insiders,slack,firefox,discord,'7zip',docker-desktop,winscp,'1password' -Source Chocolatey -Force -AcceptLicense -ForceDependencies -Confirm:$false -Verbose -InformationAction Continue | |
Start-Sleep 10 | |
$modules = @( | |
@{Name ='az'; RequiredVersion = '6.4.0' } | |
@{Name ='posh-docker'; RequiredVersion = '0.7.1 ' } | |
@{Name ='posh-git' ; RequiredVersion = '0.7.3' } | |
@{Name ='BetterCredentials'; RequiredVerson = '4.5' } | |
@{Name ='PnP.PowerShell'; RequiredVersion = '1.7.0' } | |
@{Name ='PSScriptAnalyzer'; RequiredVersion = '1.20.0' } | |
@{Name ="PowerShellGet"; RequiredVersion = '2.2.5' } | |
@{Name ="PowerShellHumanizer"; RequiredVersion = '3.2' } | |
@{Name ="Pester"; RequiredVersion = '4.10.1' } | |
@{Name ="Microsoft.PowerShell.SecretManagement"; RequiredVersion = '1.1.0' } | |
) | |
Install-Module $modules -Force -Repository PSGallery -SkipPublisherCheck -AllowClobber -Verbose | |
Enable-PSRemoting -Force -SkipNetworkProfileCheck | |
Enable-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V-All, Containers, Containers-DisposableClientVM, Microsoft-Windows-Subsystem-Linux, VirtualMachinePlatform -Online -verbose | |
Disable-WindowsOptionalFeature -FeatureName MicrosoftWindowsPowerShellV2, MicrosoftWindowsPowerShellV2Root -Online -NoRestart -Verbose | |
Get-WindowsCapability -Name RSAT* -Online | Add-WindowsCapability -Online | |
Get-WindowsCapability -Name OpenSSH* -Online | Add-WindowsCapability -Online | |
git config --global core.editor "code --wait" | |
git config --global init.defaultBranch main | |
git config --global diff.tool vscode | |
Restart-Computer -Force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you can't set things in HKLM (due to lockdown policies or you not having Admin rights) you can with the
Enable-PSTransciription
Function write to HKCU instead (or as well as) for user level transcription needs