Windows: Difference between revisions

From Cheatsheet
Jump to navigationJump to search
No edit summary
No edit summary
Line 2: Line 2:


== Important applications ==
== Important applications ==
=== SSH ===
'''SSH'''
* MobaxTerm - https://mobaxterm.mobatek.net/
* MobaxTerm - https://mobaxterm.mobatek.net/
* Putty & Puttygen - https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
* Putty & Puttygen - https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
'''Code'''
VSCodium


== Powershell ==
== Powershell ==
Line 34: Line 37:
</syntaxhighlight>
</syntaxhighlight>


==== Tasks ====
==== Shutdown or restart ====
<syntaxhighlight lang='bash'>
# Shutdown the computer
shutdown /s
 
# Restart the computer
shutdown /r
 
# Shutdown the computer in 200 seconds
shutdown /t 200
 
# Abort a timed shutdown
shutdown /a
</syntaxhighlight>
 
==== Windows Update ====
https://learn.microsoft.com/en-us/windows-server/administration/server-core/server-core-servicing
https://learn.microsoft.com/en-us/windows-server/administration/server-core/server-core-servicing


<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
# Open User Management
# Check current configured settings
lusrmgr.msc
%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
</syntaxhighlight>
 
==== Sysprep ====
# Download and install updates;
# Restart;
# Repeat step 1 and 2 until no more updates are available;
# Set the proper timezone;
# Set proper keyboard/region format;
# Activate your license;
# OPTIONAL: Make a snapshot before the sysprep
# Perform a Sysprep (see commands below)
 
<syntaxhighlight lang='bash'>
# 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
</syntaxhighlight>
</syntaxhighlight>



Revision as of 08:47, 8 September 2023


Important applications

SSH

Code VSCodium

Powershell

Checks

# 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

Common =

Commands

# Open User Management
lusrmgr.msc

Shutdown or restart

# Shutdown the computer
shutdown /s

# Restart the computer
shutdown /r

# Shutdown the computer in 200 seconds
shutdown /t 200

# Abort a timed shutdown
shutdown /a

Windows Update

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

# 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

Sysprep

  1. Download and install updates;
  2. Restart;
  3. Repeat step 1 and 2 until no more updates are available;
  4. Set the proper timezone;
  5. Set proper keyboard/region format;
  6. Activate your license;
  7. OPTIONAL: Make a snapshot before the sysprep
  8. 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

# 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