PowerShell content save to notepad

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

hi everyone and mvp’s :smiley:

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 :smiley:
by mjolinor at 2013-03-05 19:23:35
Glad to help! Come back and see us again!