Commands
This page includes both cmd and powershell commands, realistically, all of them should run from powershell anyway.
ipconfig
The ipconfig command is a command-line utility used to display and manage the IP address assigned to a machine. It provides information about the current TCP/IP network configuration, including the IP address, subnet mask, and default gateway for all adapters . In Windows, typing ipconfig without any parameters displays the computer's currently assigned IP, subnet mask, and default gateway addresses. Additional parameters can be used to perform various actions, such as releasing and renewing IP addresses, flushing the DNS cache, and displaying DNS information.
ipconfig
Displays the basic TCP/IP configuration for all adapters.
ipconfig /all
Displays the full TCP/IP configuration for all adapters.
ipconfig /release
Releases the IP address assigned to the computer.
ipconfig /renew
Renews the IP address assigned to the computer.
ipconfig /flushdns
Purges the DNS resolver cache.
ipconfig /registerdns
Refreshes all DHCP leases and re-registers DNS names.
ipconfig /displaydns
Displays the contents of the DNS cache.
ipconfig /showclassid
Displays the DHCP class ID for network adapters.
ipconfig /setclassid
Sets the DHCP class ID for network adapters.
ipconfig /allcompartments
Displays the full TCP/IP configuration for all adapters, including all compartments.
ipconfig /release6
Releases the IPv6 address assigned to the computer.
ipconfig /renew6
Renews the IPv6 address assigned to the computer.
ipconfig /showclassid6
Displays the IPv6 DHCP class ID for network adapters.
ipconfig /setclassid6
Sets the IPv6 DHCP class ID for network adapters.
ipconfig /flushdns6
Purges the IPv6 DNS resolver cache.
USE THIS IF WINDOWS IS ACTING UP HELLA WEIRD
The DISM /Online /Cleanup-Image /RestoreHealth
command is used to scan for corruption in the Windows image and repair any issues found. DISM stands for Deployment Image Servicing and Management, and it is a command-line tool used to service and prepare Windows images for deployment, recovery, and setup.
When you run the DISM /Online /Cleanup-Image /RestoreHealth
command, it performs the following tasks:
Scans the Windows image for corruption and identifies any issues. Verifies the integrity of the system file backups in the Component Store by comparing them against known good copies from the Windows Update servers. Attempts to repair any corruption found in the Windows image by replacing the corrupted files with the known good copies.
It's important to note that running this command requires administrative privileges, and it may take some time to complete, depending on the system and the extent of the corruption.
-open cmd in admin
DISM /Online /Cleanup-Image /RestoreHealth
-after running DISM, run this right after, if errors are found, it will fix it, reboot pc
SFC /scannow
-after reboot, run CMD as admin and run again
SFC /scannow
-Let's not forget the G.O.A.T., Use in Run to reset internet settings especially if you are having connecting MS app online or if Sonicwall Netextender breaks the connection
RunDll32.exe InetCpl.cpl,ResetIEtoDefaults
How to find mapped drives on cmd:
Open the Run dialog box by pressing the Windows key + R.
Type "cmd" and press Enter to open the Command Prompt.
Type net use
and press Enter to see a list of all mapped network drives.
Find the drive you want to reconnect and take note of its name.
Type net use <drive letter>: /delete
and press Enter to delete the mapping.
Type net use <drive letter>: \server\share /persistent:yes
and press Enter to
recreate the mapping with the "persistent" option, which should keep the mapping
alive even after a disconnect.
Create a Local user with CMD and make it into Admin, IF The username has a period in between please use the quotations.
net user "user.name" password /add
then
net localgroup administrators "user.name" /add
If you need to remove Admin creds
net localgroup administrators "user.name" /delete
if you need to delete the local account
net user "user.name" /delete
Disable builtin Administrator and Guest accounts:
net user "Administrator" /active:no
net user "Guest" /active:no
Disable hibernation file to resolve issues with shutdown and free up some disk space.
powercfg.exe /Hibernate off
Log off someone from a desktop session
List all sessions:
query session
Logoff the corresponding session:
logoff {number}
Fix right click on Windows 11, doesn't need admin:
reg.exe add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve
Fix alt key opening hamburger menu on ms edge [needs admin]:
reg add HKLM\SOFTWARE\Policies\Microsoft\Edge /v ConfigureKeyboardShortcuts /d {\"disabled\":[\"focus_settings_and_more\"]}
Check if the Password is Expired
Get-ADUser -identity INSERTclientUSERNAMEHERE -properties PasswordLastSet, PasswordExpired, PasswordNeverExpires | ft Name, PasswordLastSet, PasswordExpired, PasswordNeverExpires
Force the DC to sync the password
start-adsyncsynccycle -policytype delta
Join a domain
add-computer -domainname "YourDomainName" -restart
Getting New Teams to install when it refuses to [Needs Admin]
Add-ProvisionedAppPackage -Online -PackagePath "MSTeams-x64.msix" -SkipLicense
List Services and their running status
Get-Service
Set a service to autostart
Set-Service -Name {servicename} -StartupType 'Automatic'
Start/Stop a service
Start-Service {servicename} Stop-Service {servicename} Restart-Service {servicename}
Install OpenSSH-Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Remove all default gateways from a network adapter
Remove-NetRoute -InterfaceAlias "{get this name from Get-NetAdapter}" -DestinationPrefix 0.0.0.0/0
Set an IP Address
Get-NetAdapter -Name '{get this name from Get-NetAdapter}' | New-NetIPAddress -IPAddress {newIP} -PrefixLength {subnet mask [cidr]}
Allow inbound Ipv4 Pings
netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request" protocol=icmpv4:8,any dir=in action=allow
Show all WiFi Passwords [CMD Only]
for /f "skip=9 tokens=1,2 delims=:" %i in ('netsh wlan show profiles') do @if "%j" NEQ "" (echo SSID: %j & netsh wlan show profiles %j key=clear | findstr "Key Content")
Install server manager on a Non-Windows-Server OS
Get-WindowsCapability -Name RSAT* -Online | Add-WindowsCapability -Online
Force update Group Policy (apply group policy changes)
gpupdate.exe /force
Resize a VHD [Virtual Hard Disk]
resize-vhd -path "f:\Shares\profiledisks" -Sizebytes 30GB
Persistently map a drive
net use /persistent:yes h: \\VBoxSvr\Win11\Documents
Switch to compact os mode to save space
Compact.exe /CompactOS:always
Migrate a folder from one drive to the other preserving permissions and logging everything to the D:\ drive
robocopy "C:\users\awesome.guy" "D:\users\awesome.guy" /E /COPYALL /zb /r:10 /w:10 /tee /unilog+:"D:\robocopylog.txt"
Add a domain to the global dns search list
Set-DnsClientGlobalSetting -SuffixSearchList @("corp.mariocorp.com")
Fix windows update not showing in the settings page (some RMM's do this by design to handle patching themselves)
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v SettingsPageVisibility /f