Restart a machine remotely
shutdown /m \\computername /r /t 0
Winhttp set proxy
netsh winhttp set proxy proxy-server="prx.domain.net:8080" bypass-list="10.51*;*domain.gov.il;*abc.def.net"
Remove proxy
netsh winhttp reset proxy
Read text files
Read text files in cmd
more filename.txt
type abc.txt
How to do a simple file search in cmd
dir /s *foo* searches in current folder and sub folders.
It finds directories as well as files.
https://stackoverflow.com/questions/8066679/how-to-do-a-simple-file-search-in-cmd
How to Repair OS booting
- Bootrec /fixmbr
- Bootrec /fixboot
- Type bootrec /ScanOs and press Enter.
- Type bootrec /RebuildBcd and press Enter.
- Chkdsk /f /r
How to Get a List of All of the Installed Updates on Windows
How to run the SFC /SCANNOW command if your system cannot boot to Windows (Offline)
sfc /scannow /offbootdir=<Windows_Drive_Letter>:\ /offwindir=<Windows_Drive_Letter>:\windows
https://www.wintips.org/how-to-run-sfc-offline-system-file-checker-tool/
Quickly Reset NTFS Permissions in Windows 10
To reset permissions for a folder, its files, and subfolders, run the command icacls "full path to the folder" /reset /t /c /l
From <https://winaero.com/blog/reset-ntfs-permissions-windows-10/>
It is possible, but not necessarily easy. You could use /Append-Image to capture all partitions to one WIM file and then deploy each partition with DISM from that WIM file on the other side. It still isn’t a sector-based image or a disk level image, DISM is a volume imaging tool that uses WIM file-based imaging.
Another alternative is that you could Disk2VHD the reference system and then use Boot to VHD to boot the deployed systems.
From <https://superuser.com/questions/898786/dism-to-capture-entire-disk-as-is>
How to Remove Services in Windows 10
Remove services from the list in the services.msc utility in Microsoft Windows with one of these two options.
Option 1 – Command
- You can also remove services using a command line. Hold down the Windows Key, then press “R” to bring up the Run dialog.
- Type “SC DELETE servicename“, then press “Enter“.
“servicename” should be the exact name of the service.
From <https://www.technipages.com/delete-services>
Delete files and folders using CMD
If you want to retain the original directory for some reason (ACLs, &c.), and instead really want to empty it, then you can do the following:
del /q destination\*
for /d %x in (destination\*) do @rd /s /q "%x"
This first removes all files from the directory, and then recursively removes all nested directories, but overall keeping the top-level directory as it is (except for its contents).
Note that within a batch file you need to double the % within the for loop:
del /q destination\*
for /d %%x in (destination\*) do @rd /s /q "%%x"
When combined they will remove all files and folders within c:\folder but not the root folder
del /q c:\temp\* --> removes all files (not folders) within c:\temp
for /d %x in (C:\temp\PowerCLI\poer\*) do @rd /s /q "%x" - removes all folders (not files) within C:\temp\PowerCLI\poer
del /q c:\temp\* --> removes all files (not folders) within c:\temp
for /d %x in (destination\*) do @rd /s /q "%x"
for /d %x in (C:\temp\PowerCLI\poer) do @rd /s /q "%x" - removes all, including the root folder as well
for /d %x in (C:\temp\PowerCLI\poer\*) do @rd /s /q "%x" - removes all folders (not files) within C:\temp\PowerCLI\poer