Powershell: null file always generated (output of Compare-Object)

PetSerAl, as he routinely does, has provided the crucial pointer in a comment on the question: Member-access enumeration – the ability to access a member (a property or a method) on a collection and have it implicitly applied to each of its elements, with the results getting collected in an array, was introduced in PSv3.[1] … Read more

Adding a directory to the PATH environment variable in Windows

Option 1 After you change PATH with the GUI, close and re-open the console window. This works because only programs started after the change will see the new PATH. Option 2 This option only affects your current shell session, not the whole system. Execute this command in the command window you have open: set PATH=%PATH%;C:\your\path\here\ … Read more

What is the reason for “X is not recognized as an internal or external command, operable program or batch file”?

A) How does Windows command processor search for commands? Windows command processor searches for a COMMAND to execute which is not an internal command of cmd.exe and is just specified with file name without file extension and without path for a file matching the pattern command.* and having a file extension listed in local environment … Read more

How do I get current date/time on the Windows command line in a suitable format for usage in a file/folder name?

See Windows Batch File (.bat) to get current date in MMDDYYYY format: @echo off For /f “tokens=2-4 delims=/ ” %%a in (‘date /t’) do (set mydate=%%c-%%a-%%b) For /f “tokens=1-2 delims=/:” %%a in (‘time /t’) do (set mytime=%%a%%b) echo %mydate%_%mytime% If you prefer the time in 24 hour/military format, you can replace the second FOR line … Read more

How can you find and replace text in a file using the Windows command-line environment?

A lot of the answers here helped point me in the right direction, however none were suitable for me, so I am posting my solution. I have Windows 7, which comes with PowerShell built-in. Here is the script I used to find/replace all instances of text in a file: powershell -Command “(gc myFile.txt) -replace ‘foo’, … Read more

How does the Windows Command Interpreter (CMD.EXE) parse scripts?

We performed experiments to investigate the grammar of batch scripts. We also investigated differences between batch and command line mode. Batch Line Parser: Here is a brief overview of phases in the batch file line parser: Phase 0) Read Line: Phase 1) Percent Expansion: Phase 2) Process special characters, tokenize, and build a cached command … Read more