Editing a file from powershell

This topic contains 6 replies, has 4 voices, and was last updated by Profile photo of James Krusic James Krusic 6 months, 1 week ago.

  • Author
  • #61983
    Profile photo of flouflis


    i am a newbie regarding powershell, i have searched the internet with no luck.

    my question is, is there a way to open a text file inside powershell and edit it live?

    for instance, instead of typing: notepad c:\textfile.txt
    a window of the textfile opens, edit it, click save and close.
    just to open the contend inside powershell, edit them there, and click save somehow.

    i remember, back when i was a student, in linux was possible, can't figure out how to do it in a powershell,

    thanks in advance.

  • #61986
    Profile photo of Olaf Soyk
    Olaf Soyk

    Hmmm ... what did you search for? It's hard to believe that you don't find one of the simplest tasks. You might start learning the Powershell basics. Here are some great free sources to look at:


    BTW: A quick Google search for "powershell edit text file line" brought up this as the first hit:


    So you might even improve your search skills a little bit. 😉

    • #61987
      Profile photo of flouflis

      thank you for your answer, but this not what i am looking for.

      i do not want to replace, change, delete or in general do something to a text file.

      i want the text file and it's contents to been shown inside powershell, and have the full control
      of the content inside powershell to edit them (do whatever i want using my mouse, or arrows to navigate)

      it's like having notepad in front of me, but powershell instead.

  • #61989
    Profile photo of Olaf Soyk
    Olaf Soyk

    Why do you want to do Powershell the job of an editor? That doesn't make that much sense for me.

    To show the content of a text file you can use the cmdlet Get-Content.

  • #61990
    Profile photo of Don Jones
    Don Jones

    PowerShell doesn't have anything like Nano or Vi, no. That's more a lack of Windows than PowerShell per se; PowerShell is just a command language. Windows hasn't really ever had a console editor. I haven't looked to see if some third party has made one or not, but that might be an option.

  • #61992
    Profile photo of Olaf Soyk
    Olaf Soyk

    If you're looking for an IDE – the Powershell_ISE comes with Powershell or the MS Visual Studio Code with the Powershell extension does a good job I think.

  • #61993
    Profile photo of James Krusic
    James Krusic

    So vi would be like psedit inside powershell ise using v5. Vi just opens the item to be edited inside the vi component much like editing a script inside ise.

You must be logged in to reply to this topic.