# Windows Quick Commands and Tips

# Get file hash

Get-FileHash .\rhel-server-7.9-x86_64-dvd.iso -Algorithm SHA256

# Get hardware information

wmic memorychip get DeviceLocator,Manufacturer,PartNumber,Speed,Capacity

# Change the RDP listener port

① Open the registry and navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp.
② Change PortNumber value.

PortNumber

③ After you change the port number, restart the Remote Desktop Services service.
④ Firewall enable the RDP port.

# Disable Windows 10/11 Updates

services.msc -> Windows Updates -> Disabled
gpedit.msc -> Windows Update -> Configure Automatic Updates -> Disabled

# Replaces ACLs with default inherited ACLs for all matching files

ICACLS [dir] /RESET [/T] [/C] [/L] [/Q]

# Find which process in using TCP or UDP port and terminate it

netstat -ano | findstr "7890"
taskkill /T /F /PID 18484

# Quick command to access Network Control Panel

ncpa.cpl

# Managing user accounts

netplwiz

# Windows 10/11 bypass online mircosoft account

Press Shift + F10, type OOBE\BYPASSNRO , on 25H2 and newer, type start ms-cxh:localonly .

# Windows 11 bypass TPM or CPU

① Press Shift + F10, type regedit .
② Find HKEY_LOCAL_MACHINE\SYSTEM\Setup\MoSetup, New DWORD (32-bit) Value, name AllowUpgradesWithUnsupportedTPMOrCPU, data 1.
③ Find HKEY_LOCAL_MACHINE\SYSTEM\Setup, New Key LabConfig.
④ Find HKEY_LOCAL_MACHINE\SYSTEM\Setup\LabConfig, New DWORD (32-bit) Value, name BypassTPMCheck and BypassSecureBootCheck, data 1.

reg add "HKLM\SYSTEM\Setup\MoSetup" /v AllowUpgradesWithUnsupportedTPMOrCPU /t REG_DWORD /d 1 /f

reg add "HKLM\SYSTEM\Setup\LabConfig" /v BypassTPMCheck /t REG_DWORD /d 1 /f
reg add "HKLM\SYSTEM\Setup\LabConfig" /v BypassSecureBootCheck /t REG_DWORD /d 1 /f
reg add "HKLM\SYSTEM\Setup\LabConfig" /v BypassRAMCheck /t REG_DWORD /d 1 /f
reg add "HKLM\SYSTEM\Setup\LabConfig" /v BypassStorageCheck /t REG_DWORD /d 1 /f
reg add "HKLM\SYSTEM\Setup\LabConfig" /v BypassCPUCheck /t REG_DWORD /d 1 /f

# Firewall

# SMB
New-NetFirewallRule -DisplayName "Allow SMB (TCP 445)" -Direction Inbound -Protocol TCP -LocalPort 445 -Action Allow -Profile Any
New-NetFirewallRule -DisplayName "Allow NetBIOS Session (TCP 139)" -Direction Inbound -Protocol TCP -LocalPort 139 -Action Allow -Profile Any
New-NetFirewallRule -DisplayName "Allow NetBIOS NameServ (UDP 137-138)" -Direction Inbound -Protocol UDP -LocalPort 137-138 -Action Allow -Profile Any
Get-NetFirewallRule -DisplayName "Allow SMB (TCP 445)" | Select-Object Name,DisplayName,Enabled,Action

# System Fix

DISM /Online /Cleanup-image /Checkhealth
DISM /Online /Cleanup-image /Scanhealth
DISM /Online /Cleanup-image /Restorehealth
sfc /scannow

# ROBOCOPY

# include empty, retry wait 5s, restartable mode, 32 multi-threaded
ROBOCOPY Z:\source Y:\destination /e /w:5 /z /mt:32
# list only and write output to the log file.
ROBOCOPY Z:\source Y:\destination /e /l /ns /njs /njh /ndl /fp /log:reconcile.txt
# skip same file regardless of whether they're newer, older, or modified.
ROBOCOPY E:\assets\res X:\BaiduNetdisk\assets\res /e /w:5 /z /mt:16 /xc /xn /xo /iorate:2m
ROBOCOPY E:\Customers X:\BaiduNetdisk\SJ_Customers /e /w:5 /z /mt:16 /xc /xn /xo /iorate:1m

# ISO

・ https://massgrave.dev/windows_8.1_links

Edited on