Batch File Comment (Remark) – Windows

A batch file (batch script) in Windows is a text file that typically has a .bat extension and includes one or more command prompt commands.

It is a good practice to comment a source code in a batch file by leaving the remarks that explain functionality of some lines or blocks of code.

Also any line or a block of code in a batch file can be disabled by turning it into a comment (comment out) and enabled back (uncomment).

This note shows how to comment batch files in Windows. (more…)

Windows: `Touch` Command – Equivalent

The touch command in Linux is used to change a file’s “Access“, “Modify” and “Change” timestamps to the current time and date, but if the file doesn’t exist, the touch command creates it.

If you simply want to create an empty file from the command-line prompt (CMD) or a Windows PowerShell – the type and copy commands can be considered as a Windows touch command equivalent.

The file timestamps in Windows can be changed using the built-in PowerShell commands. (more…)

Windows: Shutdown/Reboot Event IDs – Get Logs

While troubleshooting an issue that causes an unexpected reboot or shutdown of a Windows machine, it is important to know which event IDs are related to system reboot/shutdown and how to find the appropriate logs.

In this note i am publishing all the event IDs related to reboots/shutdowns.

I am also showing how to display the shutdown events with date and time, using a Windows Event Viewer or from the command-line using a PowerShell. (more…)

PowerShell Commands History File Location

The Get-History command in PowerShell lists only the commands entered during the current session, unlike the history command in Linux or MacOS, that returns the full commands history across all sessions.

To get the history of all the previously executed commands in PowerShell it is required to locate the file where these commands are stored.

In this note I’ll show how to locate the history file and get the history of all the previously executed commands in PowerShell. (more…)

PowerShell: Check If Port is Open – Test TCP Connection

During troubleshooting of different issues it is often required to check if some TCP port on a remote host is opened and ensure that it is not blocked by a firewall.

The most common tool for this is telnet, but it may not be installed or you may want to be able to copy the output to paste it into a ticket or to send it someone, that is not always possible with telnet.

Also the telnet command is not very handy if you need to check connectivity to multiple hosts/ports, but you can do this easily with a PowerShell.

In Windows, you can test connection to TCP port from the command line using PowerShell and in this note i will show how to do this. (more…)