How to use Powershell for simple CMD tools


  1. Posts : 6
    Win 10 pro 64 bit
       #1

    How to use Powershell for simple CMD tools


    I am by no standard a programmer. But in the past, I had a job with a lot of skutwork needed on a daily basis. I.T. was always too busy, and non-I.T. folks were not allowed to do any programming, but the command line and batch stuff was not real programming and was OK for ordinary folks. So, I learned batch, out of necessity over 20 years ago, and became addicted. I would not even dabble with Powershell, except that it has a feature that is frustratingly missing in CMD.exe--Powershell has a command line history that is preserved between sessions.

    I have a toolkit full of little batch files that continue to make my day more comfortable, many run from shortcut icons, but many from the command-line. Many of the DOS commands work just fine in Powershell, but one which I use extensively fails. FOR throws an error. e.g.

    for /f %i in (alpha.txt) do f ...%i%i......

    where "F" is a small batch that I wrote, runs fine at the CMD prompt, but FOR creates confusion for Powershell.

    Any suggestion how I can configure Powershell to treat FOR like a CMD command? (hopefully without going too far into the mysteries of real Powershell lingo.)
      My Computer


  2. Posts : 17,661
    Windows 10 Pro
       #2

    I recommend you start with this: Windows PowerShell: Scripting Crash Course | TechNet Magazine. Read it through, it's not too complicated and with your batching background you get it.

    When done continue with this: Conditional Logic Using Loops | PowerShell Pro! :: PowerShell Pro!

    Kari
      My Computer


  3. Posts : 6
    Win 10 pro 64 bit
    Thread Starter
       #3

    Thanks Kari. I had composed a long-winded tirade about Powershell and all its irritations, but you got me within sight of my objective. After I had vented, I clicked "Mark Solved" and the forum lost my train of thought. (probably better that way)
      My Computer


  4. Posts : 14,046
    Windows 11 Pro X64 22H2 22621.1848
       #4

    Two great links, thanks Kari.
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 06:07.
Find Us




Windows 10 Forums