• Powershell for Smart But Ignorant Users

    Home » Forums » Developers, developers, developers » DevOps Lounge » Powershell for Smart But Ignorant Users

    Author
    Topic
    #2375378

    (This is a copy of a post I made two days ago in Eileen’s Lounge, which redirected me here) I am using PowerShell version 5, I believe (attached image). I continue to wade through online documentation.

     

    I cannot go on asking for help with automating my beloved BATch files and SUBST commands.
    So I will grit my teeth, those few that are left, and have a shot at using Powershell in Windows 10.

    I have set myself a few objectives in the general area of “Automating the [Re]Boot Process”
    (1) Start Notepad
    (2) Open a Text File with Notepad
    (3) Decrypt an Encrypted Data Partition
    (4) Create a Daily “Blotter Folder” as Drive B:
    (5) Execute a Dos Batch File

    These five types of task are aimed at
    (a) Weaning me away from an AutoExec.bat
    (b) Making me familiar with basic aspects of Powershell
    (c) Making me familiar with basic aspects of Group Policy Editor
    (d) Building a simple guide for folks like me

    Question: Do these objectives seem reasonable?

    There is not much that I do in my auto-boot DOS-CMD sequence apart from these basic skills.

    Every man and his dog has Notepad.exe, which is why I chose it as a specific example of “opening an existing file”, and I have a great deal invested in batch files (loading MSWord2003, opening specific VBA application programs, purging temporary files, initiating RoboCopy backups etc.

    I reason that once I have some basic benchmarks (I still think of them as job-decks!) in place, I can use those benchmarks to extend my skills and gradually translate my old DOS-CMD batch files into Powershell scripts.
    Thanks
    Chris

    Unless you're in a hurry, just wait.

    Viewing 3 reply threads
    Author
    Replies
    • #2375465

      1. Open Powershell console, type notepad.exe then press Return/Enter.

      2. Open Powershell console, type <name_of_textfile>.txt then press Return/Enter.

      3. Who knows without further info about what you used to encrypt.

      4. I have no idea what a daily blotter is.

      5. start <name of batch file>.bat

    • #2375473

      Chris,

      I’d suggest several free on-line books about powershell:

      Mastering Windows PowerShell Scripting is a good place to start.
      There are also some very good turtorials on YouTube.  Just go to YouTube and search for PowerShell Tutorials.

      For more specific help try posting the .bat files you want to convert here so we can take a look.

      HTH 😎

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

      1 user thanked author for this post.
      • #2376326

        Hi RG, and thanks for answering my question “Question: Do these objectives seem reasonable?“. I gather from your response that my objectives seem reasonable, and I shall read the proffered documentation and make a start.

         

        I shall start with a simple auto-bat that loads Notepad.exe, assemble the relevant PowerShell command and then try to make that work at re-boot time. My next appearance here will be recognizable by my bloodied and battered body with a desire for a clue as to “what went wrong”, and evidence of the cause for my singed eyebrows!

        I hope that once I have a functioning boot sequence I can modify the boot script to adapt to new tasks.

        My current (DOS BATch file “Auto20210707.bat” weighs in at 63 lines, most of which are comments, and I fancy remodeling that one feature at a time. It should be possible form me to have both boot sequences working and deplete the BAT file while I augment the PS script, one functional component at a time.

        No more from me until after my first attempt.

        Thanks again, Chris

        Unless you're in a hurry, just wait.

    • #2375486

      Introduction to PowerShell – A quick Microsoft tutorial in 7 modules.

      Windows PowerShell Scripting Tutorial for Beginners – includes a tutorial you can download.

      PowerShell 101 – Online book which you can tailor for different versions of PowerShell by using the dropdown on top-left. (The link is for PowerShell v5.1.)

      Specifically, have a look at Restart-Computer and the examples shown.

      If it’s Bitlocker you want to decrypt, use:

      Disable-BitLocker -MountPoint "X:"

      … replacing X: with whatever drive you want. Note that this needs to be run elevated, e.g. using the Windows PowerShell (Admin) option.

      The PS equivalent to SUBST is New-PSDrive, e.g.:

      New-PSDrive -Name x -PSProvider FileSystem -Root c:\myfolder1\myfolder2\

      However, SUBST still works from within PowerShell.

      1 user thanked author for this post.
    • #2376325

      Hi Rick. My apologies for a tardy reply, but weather (warm and sunny) has seen me trapped in my garden!

      I am a bit of a dab hand at automating things, just not hands-free with PowerShell.

      Hence my thrust here is “the general area of “Automating the [Re]Boot Process”” but with PowerShell.

      I have dabbled in PowerShell for maybe an hour and initiated commands manually though a PowerShell window – very much like typing DOS commands in a CMD.EXE window, with an overwhelming variety of options, so (as an example) firing-up Notepad is not the problem as much as is “firing up Notepad at reboot time”.

      I suspect that the web has a boundless supply of scripts, and I will find most of them, but right now I am baulked at getting that first replacement structure for an Auto.bat in the Win10 folder “C:\Users\Chris075\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup”.

      Let me respond to RetiredGeek’s post and than come up with a failed attempt at Startup and we can take it from there!

      Thanks

      Chris

      Unless you're in a hurry, just wait.

    Viewing 3 reply threads
    Reply To: Powershell for Smart But Ignorant Users

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: