PowerShell content save to notepad

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of Forums Archives Forums Archives 5 years, 5 months ago.

  • Author
    Posts
  • #5630

    by charles00d at 2013-03-05 18:43:38

    hi everyone and mvp's 😀

    i've just started using powershell and really dont know much. i have this code:

    @echo off
    Powershell -noexit "ipconfig /displaydns | select-string 'Record Name' | foreach-object { $_.ToString().Split(' ')[-1] } | Sort | Out-Gridview"

    how do i save the output into a txt file format?

    thanks

    by mjolinor at 2013-03-05 18:51:13

    Just trade Out-Gridview for Set-Content or Out-File:

    Powershell -noexit "ipconfig /displaydns | select-string 'Record Name' | foreach-object { $_.ToString().Split(' ')[-1] } | Sort | Set-Content c:\somedir\file.txt"

    by charles00d at 2013-03-05 19:02:58

    thank you mjolinor you're a savior woooooooooooo 😀

    by mjolinor at 2013-03-05 19:23:35

    Glad to help! Come back and see us again!

You must be logged in to reply to this topic.