Install and remove stuff.
Instalation
shift
+F10
- Launch CMD
Basic
Enable administrator account
You can also remove the created user from the group "Administrators" and add it to "Users".
Change the name of the computer
Enable RDP
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -value 0
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
Enable-NetFirewallRule -DisplayGroup "Escritorio Remoto" # Spanish
Or in Start > Settings > System > Remote Desktop, and turn on Enable Remote Desktop.
Allow current user
Add-LocalGroupMember -Group "Remote Desktop Users" -Member $env:USERNAME
Add-LocalGroupMember -Group "Usuarios de escritorio remoto" -Member UserNameGoesHere
Enable SSH
Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Start-Service sshd
Set-Service -Name sshd -StartupType 'Automatic'
Set-Service -Name sshd -Status Running -PassThru
Get-NetFirewallRule -Name *ssh*
:New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
/etc/ssh/
is at C:\ProgramData\ssh\
Keys fingerprint
PS C:\Users\Administrator> ssh-keygen -lf C:\ProgramData\ssh\ssh_host_ed25519_key.pub
256 SHA256:hTXki9gTP1xdLVtwhfIz3BoeICbRMbjp4T13B4gXDCA nt authority\system@WIN-DK1HACEJIQ3 (ED25519)
Basic config.
Restart the service
Add a public key for a normal user
md C:\Users\Administrator\.ssh\
New-Item -Path 'C:\Users\Administrator\.ssh\authorized_keys' -ItemType File
notepad C:\Users\Administrator\.ssh\authorized_keys
---
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMos4v3Xo9YyhBHn4W428P7ra6Zxs+wpzteTF1TFiJnY yu
Add a public key for an admin user.
md %programdata%/ssh
New-Item -Path "C:\ProgramData\ssh\administrators_authorized_keys" -ItemType File
notepad C:\ProgramData\ssh\administrators_authorized_keys
---
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMos4v3Xo9YyhBHn4W428P7ra6Zxs+wpzteTF1TFiJnY yu
---
$acl = Get-Acl C:\ProgramData\ssh\administrators_authorized_keys
$acl.SetAccessRuleProtection($true, $false)
$administratorsRule = New-Object system.security.accesscontrol.filesystemaccessrule("Administrators","FullControl","Allow")
$systemRule = New-Object system.security.accesscontrol.filesystemaccessrule("SYSTEM","FullControl","Allow")
$acl.SetAccessRule($administratorsRule)
$acl.SetAccessRule($systemRule)
$acl | Set-Acl
Repair permissions of the new file
$ConfirmPreference = 'None'; Repair-AuthorizedKeyPermission C:\Users\Administrator\.ssh\authorized_keys
You can also do something like this: scp ~/.ssh/id_ed25519.pub user1@domain1@contoso.com:C:\Users\user1\.ssh\authorized_keys
Connect
Disable updates
Disable the service
To install some features, it is necessary.
set-service wuauserv -StartupType manual
#set-service wuauserv -status running
Start-Service wuauserv
Remove the tasks
https://docs.microsoft.com/en-us/powershell/module/scheduledtasks/?view=windowsserver2019-ps
Install software
Chocolatey
Install chocolatey. PS as Admin.
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Search and install packages.
Update all.
Remove a package.
Create shortcuts to chocolatey installed binaries in CMD.
mklink /D %HOMEPATH%\Desktop\chocolib C:\ProgramData\chocolatey\lib
mklink /D %HOMEPATH%\Desktop\chocobin C:\ProgramData\chocolatey\bin
Add and remove Windows features
List all features and show the status.
Search for Windows features.
Get-WindowsOptionalFeature -Online -FeatureName Containers
Get-WindowsOptionalFeature -Online -FeatureName Containers-DisposableClientVM
Sometimes the name does not match like in Windows Sandbox
which is named Containers-DisposableClientVM
.
Add a Windows feature. Needs a reboot.
Remove a Windows Feature. Needs a reboot.
Uninstall software
Remove installed "Apps".
Get-AppxPackage | Select Name, PackageFullName
Get-AppxPackage Microsoft.BingWeather | Remove-AppxPackage
Disable services.
Remove bloat
Windows updates