Windows: Difference between revisions

From Cheatsheet
Jump to navigationJump to search
Line 54: Line 54:
# Open User Management
# Open User Management
lusrmgr.msc
lusrmgr.msc
# Add this machine (SRV01) to domain clinic.local, use server 192.168.77.11 as reachable Domain Controller and ask for a password prompt for security
NETDOM ADD SRV01 /Domain:clinic.local /UserD:Administrator /PasswordD:* /Server:192.168.77.11 /SecurePasswordPrompt
</syntaxhighlight>
</syntaxhighlight>



Revision as of 10:13, 20 September 2023


Important applications

SSH

Code

  • VSCodium

Windows management

Hypervisors

  • Hyper-V
  • VirtualBox
  • VMWare Worststation

Powershell

Network

# List open ports and related IP-addresses
Get-NetTCPConnection

# "To show only the listening ports we need to filter for all items in the Listen state with the remote address of 0.0.0.0"
get-nettcpconnection | where {($_.State -eq "Listen") -and ($_.RemoteAddress -eq "0.0.0.0")}

# "You can add additional fields like the process ID for each port. Changing the fields from the default requires selecting each one you want and then piping to ft (format-table)."
get-nettcpconnection | where {($_.State -eq "Listen") -and ($_.RemoteAddress -eq "0.0.0.0")} | Select LocalAddress,LocalPort,RemoteAddress,RemotePort,State,OwningProcess | ft

# "This example will get the name of the process associated with each item."
get-nettcpconnection | where {($_.State -eq "Listen") -and ($_.RemoteAddress -eq "0.0.0.0")} | select LocalAddress,LocalPort,RemoteAddress,RemotePort,State,@{Name="Process";Expression={(Get-Process -Id $_.OwningProcess).ProcessName}} | ft

# Test the network-connection to a specific IP and port
Test-NetConnection -ComputerName 192.168.200.20 -InformationLevel "Detailed" -Port 443

Command Prompt

Checks

# Open the System information window
msinfo32

Common

Commands

# Open Server Configuration menu
sconfig

# Open User Management
lusrmgr.msc

# Add this machine (SRV01) to domain clinic.local, use server 192.168.77.11 as reachable Domain Controller and ask for a password prompt for security
NETDOM ADD SRV01 /Domain:clinic.local /UserD:Administrator /PasswordD:* /Server:192.168.77.11 /SecurePasswordPrompt

Shutdown or restart

# Shutdown the computer
shutdown /s

# Restart the computer (60 seconds time-out)
shutdown /r

# Shutdown the computer in 200 seconds
shutdown /t 200

# Restart the computer right now
shutdown /r /t 0

# Abort a timed shutdown
shutdown /a

Windows Update

https://learn.microsoft.com/en-us/windows-server/administration/server-core/server-core-servicing

# For Windows Server Core, use the sconfig menu for easy Windows Update configuration
sconfig
# Check current configured settings
%systemroot%\system32\Cscript %systemroot%\system32\scregedit.wsf /AU /v

# Disable automatic updates
Net stop wuauserv
%systemroot%\system32\Cscript %systemroot%\system32\scregedit.wsf /AU 1
Net start wuauserv

# Enable automatic updates
Net stop wuauserv
%systemroot%\system32\Cscript %systemroot%\system32\scregedit.wsf /AU 4
Net start wuauserv

# Update and install updates
Wuauclt /detectnow

License

# For Windows Server Core, use the sconfig menu for easy license installation and activation
sconfig
# Install a license key
slmgr.vbs /ipk ASDI1-POQW2-QOWE5-ASDP0-QWEI3

# Activate installed license key
slmgr.vbs /dli

# Verify active license
slmgr.vbs /dli

Sysprep

  1. Download and install updates;
  2. Restart;
  3. Repeat step 1 and 2 until no more updates are available;
  4. Disable automatic updates;
  5. Set the proper timezone;
  6. Set proper keyboard/region format;
  7. Activate your license;
  8. Enable Remote Desktop - "Allow remote connections to this computer"
  9. OPTIONAL: Make a snapshot before the sysprep;
  10. Perform a Sysprep (see commands below).
# Sysprep
C:\Windows\System32\Sysprep\sysprep.exe /generalize /shutdown

# Sysprep using an unattend.xml
C:\Windows\System32\Sysprep\sysprep.exe /generalize /shutdown /unattend:C:\Windows\System32\Sysprep\unattended.xml

Network

# For Windows Server Core, use sconfig for easy configuration
sconfig
# Add a route for a specific network
route add 192.168.15.0 mask 255.255.255.0 192.168.15.1

# Delete a route for a specific network
route delete 192.168.15.0 mask 255.255.255.0 192.168.15.1