Command Line examples

Ping with timestamp
ping -t server1.contoso.com|cmd /q /v /c “(pause&pause)>nul & for /l %a in () do (set /p “data=” && echo(!date! !time! !data!)&ping -n 2 server1.contoso.com>nul”

Get Index content of Install.wim file
Dism /get-wiminfo /wimfile::\sources\install.wim

Check Windows Firewall status on remote computer
netsh -r laptop1 advfirewall show allprofiles

Install .NET 3.51 on Windows 8.1
Dism.exe /online /enable-feature /featurename:NetFX3 /All /Source:D:\sources\sxs /LimitAccess

Check if Repair Your Computer option is Enabled. If not, how to enable it
reagentc/info (tells you about the bootmenu and actual winre)
reagentc/enable (adds it from boot menu)
reagentc/disable (removes it from boot menu)

Check if TPM is installed (use with psexec.exe for remote computer)
c:\windows\system32\wbem\wmic.exe /namespace:\\root\CIMV2\Security\MicrosoftTPM path Win32_Tpm get /value

Location for batch scripts at start-up
shell:startup

Update group policy for just computer targeted GPOs
gpupdate /target:computer

Find vendor and model
wmic computersystem get model,manufacturer

Find Serial Number
wmic bios get serialnumber

Find OS Version (Windows 7/Server 2008 and later)
systeminfo | findstr /B /C:”OS Name” /C:”OS Version”

Run a batch file at boot in Windows 8 and 10 users
Create a shortcut to the batch file.
Once the shortcut has been created, right-click the file and select Cut.
Press the Start button and type Run and press enter.
In the Run window, type shell:startup to open the Startup folder.
Once the Startup folder has been opened, click the Home tab at the top of the folder and select Paste to paste the shortcut into the folder.

Enable Remote Management on Remote Complete (quietly) – requires PSTOOLS PSExec (https://technet.microsoft.com/en-us/sysinternals/dd443648.aspx)
psexec \\ -s winrm.cmd quickconfig -q

Disable Windows Firewall via regedit
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile\EnableFirewall (change to zero)

Enable Remote Desktop on Windows Client
reg add “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server” /v fDenyTSConnections /t REG_DWORD /d 0 /f

Kill Process
1. Get the PID of the hung service using: sc queryex
PID

2. Kill the specific PID: taskkill /f /pid [PID]
Kill_PID

Advertisements