Commands: Difference between revisions

No edit summary
No edit summary
Line 1: Line 1:
<hr>This page includes both cmd and powershell commands, realistically, all of them should run from powershell anyway.<hr>
This page includes both cmd and powershell commands, realistically, all of them should run from powershell anyway.


= IP Configuration (ipconfig) =


<hr>ipconfig<hr>
The ipconfig command is a command-line utility used to display and manage the IP address assigned to a machine.
 
 
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.
 
 
 
<code>ipconfig</code>


== ipconfig ==
ipconfig
Displays the basic TCP/IP configuration for all adapters.
Displays the basic TCP/IP configuration for all adapters.


 
== ipconfig /all ==
<code>ipconfig /all</code>
ipconfig /all
 
Displays the full TCP/IP configuration for all adapters.
Displays the full TCP/IP configuration for all adapters.


 
== ipconfig /release ==
<code>ipconfig /release</code>
ipconfig /release
 
Releases the IP address assigned to the computer.
Releases the IP address assigned to the computer.


 
== ipconfig /renew ==
<code>ipconfig /renew</code>
ipconfig /renew
 
Renews the IP address assigned to the computer.
Renews the IP address assigned to the computer.


 
== ipconfig /flushdns ==
<code>ipconfig /flushdns</code>
ipconfig /flushdns
 
Purges the DNS resolver cache.
Purges the DNS resolver cache.


== ipconfig /registerdns ==
ipconfig /registerdns
Refreshes DHCP leases and re-registers DNS names.


<code>ipconfig /registerdns</code>
== ipconfig /displaydns ==
ipconfig /displaydns
Displays DNS cache contents.


Refreshes all DHCP leases and re-registers DNS names.
== ipconfig (IPv6 & advanced) ==
ipconfig /allcompartments
ipconfig /release6
ipconfig /renew6
ipconfig /showclassid
ipconfig /setclassid
ipconfig /showclassid6
ipconfig /setclassid6
ipconfig /flushdns6


= Windows Repair (USE THIS IF WINDOWS IS ACTING UP HELLA WEIRD) =


<code>ipconfig /displaydns</code>
== DISM RestoreHealth ==
DISM /Online /Cleanup-Image /RestoreHealth


Displays the contents of the DNS cache.
== SFC Scan (run after DISM) ==
SFC /scannow


== SFC Scan (after reboot) ==
SFC /scannow


<code>ipconfig /showclassid</code>
= Reset Internet Settings (G.O.A.T.) =
RunDll32.exe InetCpl.cpl,ResetIEtoDefaults


Displays the DHCP class ID for network adapters.
= Network Drive Management =


== List Mapped Drives ==
net use


<code>ipconfig /setclassid</code>
== Remove Mapping ==
net use <drive letter>: /delete


Sets the DHCP class ID for network adapters.
== Recreate Mapping ==
net use <drive letter>: \\server\share /persistent:yes


== Delete All Mappings ==
net use * /delete


<code>ipconfig /allcompartments</code>
== Persistently Map Drive ==
net use /persistent:yes h: \\VBoxSvr\Win11\Documents


Displays the full TCP/IP configuration for all adapters, including all compartments.
= User Management =


== Create Local User ==
net user "user.name" password /add


<code>ipconfig /release6</code>
== Add to Administrators ==
net localgroup administrators "user.name" /add


Releases the IPv6 address assigned to the computer.
== Remove from Administrators ==
net localgroup administrators "user.name" /delete


== Delete User ==
net user "user.name" /delete


<code>ipconfig /renew6</code>
== Disable Built-in Accounts ==
net user "Administrator" /active:no
net user "Guest" /active:no


Renews the IPv6 address assigned to the computer.
= Power & System =


== Disable Hibernation ==
powercfg.exe /Hibernate off


<code>ipconfig /showclassid6</code>
== Compact OS ==
Compact.exe /CompactOS:always


Displays the IPv6 DHCP class ID for network adapters.
== Rename Computer ==
Rename-Computer -NewName "YourNewHostname"


= Sessions =


<code>ipconfig /setclassid6</code>
== List Sessions ==
query session


Sets the IPv6 DHCP class ID for network adapters.
== Logoff Session ==
logoff {number}


= Windows Fixes =


<code>ipconfig /flushdns6</code>
== Fix Windows 11 Right Click ==
reg.exe add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve


Purges the IPv6 DNS resolver cache.
== Fix Edge Alt Key ==
reg add HKLM\SOFTWARE\Policies\Microsoft\Edge /v ConfigureKeyboardShortcuts /d {"disabled":["focus_settings_and_more"]}


== Disable Widgets ==
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v TaskbarDa /t REG_DWORD /d 0


== Fix Windows Update Missing ==
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v SettingsPageVisibility /f


<hr>
= Active Directory =


== Check Password Expiry ==
Get-ADUser -identity INSERTclientUSERNAMEHERE -properties PasswordLastSet, PasswordExpired, PasswordNeverExpires | ft Name, PasswordLastSet, PasswordExpired, PasswordNeverExpires


USE THIS IF WINDOWS IS ACTING UP HELLA WEIRD
== Force AD Sync ==
start-adsyncsynccycle -policytype delta


== Join Domain ==
add-computer -domainname "YourDomainName" -restart


The <code>DISM /Online /Cleanup-Image /RestoreHealth</code> 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.
= Apps & Installation =


When you run the <code>DISM /Online /Cleanup-Image /RestoreHealth</code> command, it performs the following tasks:
== Install New Teams ==
Add-ProvisionedAppPackage -Online -PackagePath "MSTeams-x64.msix" -SkipLicense


Scans the Windows image for corruption and identifies any issues.
== Install OpenSSH ==
Verifies the integrity of the system file backups in the Component Store by comparing them against known good copies from the Windows Update servers.
Add-WindowsCapability -Online -Name OpenSSH.Server[[Special:Contributions/170.55.73.212|170.55.73.212]] 23:52, 23 March 2026 (UTC)0.0.1.0
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.
== Install RSAT ==
Get-WindowsCapability -Name RSAT* -Online | Add-WindowsCapability -Online


== Install Vim (System Wide) ==
mkdir vim-install; cd vim-install; $ProgressPreference = 'SilentlyContinue'; Invoke-Webrequest -UseBasicParsing https://github.com/vim/vim-win32-installer/releases/download/v9.1.0/gvim_9.1.0_x86_signed.zip -o gvim.zip; Expand-Archive -Path gvim.zip -DestinationPath .; cp .\vim\vim91\vim.exe C:\windows\system32\vim.exe


-open cmd in admin
== Install Vim (User Only) ==
mkdir vim-install; cd vim-install; $ProgressPreference = 'SilentlyContinue'; Invoke-Webrequest -UseBasicParsing https://github.com/vim/vim-win32-installer/releases/download/v9.1.0/gvim_9.1.0_x86_signed.zip -o gvim.zip; Expand-Archive -Path gvim.zip -DestinationPath .; cp .\vim\vim91\vim.exe %localappdata%\Microsoft\WindowsApps\vim.exe


<code>DISM /Online /Cleanup-Image /RestoreHealth</code>
== Install Git ==
 
winget install --id Git.Git -e --source winget --scope user
 
-after running DISM, run this right after, if errors are found, it will fix it, reboot pc
 
<code>SFC /scannow</code>
 
 
-after reboot, run CMD as admin and run again
 
<code>SFC /scannow</code>
 
 
 
 
 
<hr>
 
-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
 
<code>RunDll32.exe InetCpl.cpl,ResetIEtoDefaults</code>
<hr>
 
<hr>
How to find mapped drives on cmd:
 
Open the Run dialog box by pressing the Windows <code>key + R.</code>
 
Type "cmd" and press Enter to open the Command Prompt.
 
Type <code>net use</code> 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 <code>net use <drive letter>: /delete</code> and press Enter to delete the mapping.
 
Type <code>net use <drive letter>: \server\share /persistent:yes</code> and press Enter to
recreate the mapping with the "persistent" option, which should keep the mapping
alive even after a disconnect.
<hr>
 
 
 
Create a Local user with CMD and make it into Admin, IF The username has a period in between please use the quotations.
 
 
<code>net user "user.name" password /add</code>
 
 
then


<code>net localgroup administrators "user.name" /add</code>
= Services =
 
 
If you need to remove Admin creds
 
<code>net localgroup administrators "user.name" /delete</code>
 
 
if you need to delete the local account
 
<code>net user "user.name" /delete</code>
 
 
Disable builtin Administrator and Guest accounts:
 
<code>net user "Administrator" /active:no</code>
 
<code>net user "Guest" /active:no</code>
 
 
<hr>
 
Disable hibernation file to resolve issues with shutdown and free up some disk space.
 
<code>powercfg.exe /Hibernate off</code>
 
 
<hr>
Log off someone from a desktop session
 
 
List all sessions:
 
<code>query session</code>
 
Logoff the corresponding session:
 
<code>logoff {number}</code>
 
 
<hr>
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</code>
 
<hr>
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\"]}
 
<hr>
Disable Widgets button on the taskbar.
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v TaskbarDa /t REG_DWORD /d 0
 
<hr>
Check if the Password is Expired
 
Get-ADUser -identity INSERTclientUSERNAMEHERE -properties PasswordLastSet, PasswordExpired, PasswordNeverExpires | ft Name, PasswordLastSet, PasswordExpired, PasswordNeverExpires
<hr>
Force the DC to sync the password
 
start-adsyncsynccycle -policytype delta
<hr>
Join a domain
 
add-computer -domainname "YourDomainName"  -restart
 
<hr>
Getting New Teams to install when it refuses to [Needs Admin]
 
Add-ProvisionedAppPackage -Online -PackagePath "MSTeams-x64.msix" -SkipLicense
 
<hr>
List Services and their running status


== List Services ==
  Get-Service
  Get-Service


<hr>
== Set Auto Start ==
Set a service to autostart
  Set-Service -Name {servicename} -StartupType Automatic
 
  Set-Service -Name {servicename} -StartupType 'Automatic'
 
<hr>
Start/Stop a service


== Manage Service ==
  Start-Service {servicename}
  Start-Service {servicename}
  Stop-Service {servicename}
  Stop-Service {servicename}
  Restart-Service {servicename}
  Restart-Service {servicename}


<hr>
= Networking (Advanced) =
Install OpenSSH-Server
 
<nowiki>Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0</nowiki>
 
<hr>
Remove all default gateways from a network adapter


== Remove Default Gateway ==
  Remove-NetRoute -InterfaceAlias "{get this name from Get-NetAdapter}" -DestinationPrefix 0.0.0.0/0
  Remove-NetRoute -InterfaceAlias "{get this name from Get-NetAdapter}" -DestinationPrefix 0.0.0.0/0


<hr>
== Set IP Address ==
Set an IP Address
  Get-NetAdapter -Name '{get this name from Get-NetAdapter}' | New-NetIPAddress -IPAddress {newIP} -PrefixLength {cidr}
 
  Get-NetAdapter -Name '{get this name from Get-NetAdapter}' | New-NetIPAddress -IPAddress {newIP} -PrefixLength {subnet mask [cidr]}


<hr>
== Allow Ping ==
Allow inbound Ipv4 Pings
  netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request" protocol=icmpv4:8,any dir=in action=allow
  netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request" protocol=icmpv4:8,any dir=in action=allow


<hr>
== Show WiFi Passwords ==
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")
  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")


<hr>
== Disable WiFi Scanning ==
Install server manager on a Non-Windows-Server OS
netsh wlan set autoconfig enabled=no interface="Wi-Fi"
  Get-WindowsCapability -Name RSAT* -Online | Add-WindowsCapability -Online
 
== Enable WiFi Scanning ==
  netsh wlan set autoconfig enabled=yes interface="Wi-Fi"


<hr>
= Storage & Files =
Force update Group Policy (apply group policy changes)
gpupdate.exe /force


<hr>
== Resize VHD ==
Resize a VHD [Virtual Hard Disk]
  resize-vhd -path "f:\Shares\profiledisks" -Sizebytes 30GB
  resize-vhd -path "f:\Shares\profiledisks" -Sizebytes 30GB


<hr>
== Robocopy Migration ==
Persistently map a drive
  robocopy "C:\users\awesome.guy" "D:\users\awesome.guy" /E /COPYALL /zb /r:10 /w:10 /tee /unilog+:"D:\robocopylog.txt"
  net use /persistent:yes h: \\VBoxSvr\Win11\Documents


<hr>
= DNS & Group Policy =
Switch to compact os mode to save space
Compact.exe /CompactOS:always


<hr>
== Add DNS Suffix ==
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"
 
<hr>
Add a domain to the global dns search list
  Set-DnsClientGlobalSetting -SuffixSearchList @("corp.mariocorp.com")
  Set-DnsClientGlobalSetting -SuffixSearchList @("corp.mariocorp.com")


<hr>
== Force GP Update ==
Fix windows update not showing in the settings page (some RMM's do this by design to handle patching themselves)
  gpupdate.exe /force
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v SettingsPageVisibility /f
 
<hr>
Disable Wi-Fi searching. This allows for more stable wi-fi performance at the cost of being able to see networks that pop up in realtime.
netsh wlan set autoconfig enabled=no interface="Wi-Fi"
 
<hr>
Enable Wi-Fi searching. This reverts the above command.
netsh wlan set autoconfig enabled=yes interface="Wi-Fi"
 
<hr>
Install Vim One-liner (Powershell only) (SYSTEM WIDE, NEEDS ADMIN)
  mkdir vim-install; cd vim-install; $ProgressPreference = 'SilentlyContinue'; Invoke-Webrequest -UseBasicParsing https://github.com/vim/vim-win32-installer/releases/download/v9.1.0/gvim_9.1.0_x86_signed.zip -o gvim.zip; Expand-Archive -Path gvim.zip -DestinationPath .; cp .\vim\vim91\vim.exe C:\windows\system32\vim.exe
 
<hr>
Install Vim One-liner (Powershell only) (user only)
mkdir vim-install; cd vim-install; $ProgressPreference = 'SilentlyContinue'; Invoke-Webrequest -UseBasicParsing https://github.com/vim/vim-win32-installer/releases/download/v9.1.0/gvim_9.1.0_x86_signed.zip -o gvim.zip; Expand-Archive -Path gvim.zip -DestinationPath .; cp .\vim\vim91\vim.exe %localappdata%\Microsoft\WindowsApps\vim.exe


<hr>
= Misc =
Install Git One-liner
winget install --id Git.Git -e --source winget --scope user


<hr>
== Firefox Profile Manager ==
Set Hostname
Rename-Computer -NewName "YourNewHostname"
 
Run Firefox with the profile selector screen
  "C:\Program Files\Mozilla Firefox\firefox.exe" --ProfileManager
  "C:\Program Files\Mozilla Firefox\firefox.exe" --ProfileManager


<hr>
== Ping with Timestamp ==
Delete all drive mappings / remove all network drives
net use * /delete
 
Ping with timestamp (Powershell only)
  ping google.com -t | % { "$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') $_" }
  ping google.com -t | % { "$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') $_" }

Revision as of 23:52, 23 March 2026

This page includes both cmd and powershell commands, realistically, all of them should run from powershell anyway.

IP Configuration (ipconfig)

The ipconfig command is a command-line utility used to display and manage the IP address assigned to a machine.

ipconfig

ipconfig

Displays the basic TCP/IP configuration for all adapters.

ipconfig /all

ipconfig /all

Displays the full TCP/IP configuration for all adapters.

ipconfig /release

ipconfig /release

Releases the IP address assigned to the computer.

ipconfig /renew

ipconfig /renew

Renews the IP address assigned to the computer.

ipconfig /flushdns

ipconfig /flushdns

Purges the DNS resolver cache.

ipconfig /registerdns

ipconfig /registerdns

Refreshes DHCP leases and re-registers DNS names.

ipconfig /displaydns

ipconfig /displaydns

Displays DNS cache contents.

ipconfig (IPv6 & advanced)

ipconfig /allcompartments
ipconfig /release6
ipconfig /renew6
ipconfig /showclassid
ipconfig /setclassid
ipconfig /showclassid6
ipconfig /setclassid6
ipconfig /flushdns6

Windows Repair (USE THIS IF WINDOWS IS ACTING UP HELLA WEIRD)

DISM RestoreHealth

DISM /Online /Cleanup-Image /RestoreHealth

SFC Scan (run after DISM)

SFC /scannow

SFC Scan (after reboot)

SFC /scannow

Reset Internet Settings (G.O.A.T.)

RunDll32.exe InetCpl.cpl,ResetIEtoDefaults

Network Drive Management

List Mapped Drives

net use

Remove Mapping

net use <drive letter>: /delete

Recreate Mapping

net use <drive letter>: \\server\share /persistent:yes

Delete All Mappings

net use * /delete

Persistently Map Drive

net use /persistent:yes h: \\VBoxSvr\Win11\Documents

User Management

Create Local User

net user "user.name" password /add

Add to Administrators

net localgroup administrators "user.name" /add

Remove from Administrators

net localgroup administrators "user.name" /delete

Delete User

net user "user.name" /delete

Disable Built-in Accounts

net user "Administrator" /active:no
net user "Guest" /active:no

Power & System

Disable Hibernation

powercfg.exe /Hibernate off

Compact OS

Compact.exe /CompactOS:always

Rename Computer

Rename-Computer -NewName "YourNewHostname"

Sessions

List Sessions

query session

Logoff Session

logoff {number}

Windows Fixes

Fix Windows 11 Right Click

reg.exe add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve

Fix Edge Alt Key

reg add HKLM\SOFTWARE\Policies\Microsoft\Edge /v ConfigureKeyboardShortcuts /d {"disabled":["focus_settings_and_more"]}

Disable Widgets

reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v TaskbarDa /t REG_DWORD /d 0

Fix Windows Update Missing

reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v SettingsPageVisibility /f

Active Directory

Check Password Expiry

Get-ADUser -identity INSERTclientUSERNAMEHERE -properties PasswordLastSet, PasswordExpired, PasswordNeverExpires | ft Name, PasswordLastSet, PasswordExpired, PasswordNeverExpires

Force AD Sync

start-adsyncsynccycle -policytype delta

Join Domain

add-computer -domainname "YourDomainName" -restart

Apps & Installation

Install New Teams

Add-ProvisionedAppPackage -Online -PackagePath "MSTeams-x64.msix" -SkipLicense

Install OpenSSH

Add-WindowsCapability -Online -Name OpenSSH.Server170.55.73.212 23:52, 23 March 2026 (UTC)0.0.1.0

Install RSAT

Get-WindowsCapability -Name RSAT* -Online | Add-WindowsCapability -Online

Install Vim (System Wide)

mkdir vim-install; cd vim-install; $ProgressPreference = 'SilentlyContinue'; Invoke-Webrequest -UseBasicParsing https://github.com/vim/vim-win32-installer/releases/download/v9.1.0/gvim_9.1.0_x86_signed.zip -o gvim.zip; Expand-Archive -Path gvim.zip -DestinationPath .; cp .\vim\vim91\vim.exe C:\windows\system32\vim.exe

Install Vim (User Only)

mkdir vim-install; cd vim-install; $ProgressPreference = 'SilentlyContinue'; Invoke-Webrequest -UseBasicParsing https://github.com/vim/vim-win32-installer/releases/download/v9.1.0/gvim_9.1.0_x86_signed.zip -o gvim.zip; Expand-Archive -Path gvim.zip -DestinationPath .; cp .\vim\vim91\vim.exe %localappdata%\Microsoft\WindowsApps\vim.exe

Install Git

winget install --id Git.Git -e --source winget --scope user

Services

List Services

Get-Service

Set Auto Start

Set-Service -Name {servicename} -StartupType Automatic

Manage Service

Start-Service {servicename}
Stop-Service {servicename}
Restart-Service {servicename}

Networking (Advanced)

Remove Default Gateway

Remove-NetRoute -InterfaceAlias "{get this name from Get-NetAdapter}" -DestinationPrefix 0.0.0.0/0

Set IP Address

Get-NetAdapter -Name '{get this name from Get-NetAdapter}' | New-NetIPAddress -IPAddress {newIP} -PrefixLength {cidr}

Allow Ping

netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request" protocol=icmpv4:8,any dir=in action=allow

Show WiFi Passwords

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")

Disable WiFi Scanning

netsh wlan set autoconfig enabled=no interface="Wi-Fi"

Enable WiFi Scanning

netsh wlan set autoconfig enabled=yes interface="Wi-Fi"

Storage & Files

Resize VHD

resize-vhd -path "f:\Shares\profiledisks" -Sizebytes 30GB

Robocopy Migration

robocopy "C:\users\awesome.guy" "D:\users\awesome.guy" /E /COPYALL /zb /r:10 /w:10 /tee /unilog+:"D:\robocopylog.txt"

DNS & Group Policy

Add DNS Suffix

Set-DnsClientGlobalSetting -SuffixSearchList @("corp.mariocorp.com")

Force GP Update

gpupdate.exe /force

Misc

Firefox Profile Manager

"C:\Program Files\Mozilla Firefox\firefox.exe" --ProfileManager

Ping with Timestamp

ping google.com -t | % { "$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') $_" }