out-file to a line not the end


hi guys,

i have script problem i'm trying resolve. want user can edit single line of txt tile. possible using out-file command?

"out-file 'c:\temp.txt' -append -inputobject $user_input"

this add line end of file, that's not want do. suppose have text file looks this.

1.hello

2. dad

3. mum

and want edit hello bye. why can't do:

"out-file 'c:\temp.txt'[0] -append -inputobject $user_input"

when run nothing happens. ideas?

hi!

that's not possible out-file. check out:

https://social.technet.microsoft.com/forums/scriptcenter/en-us/6ad028d9-551a-4934-b200-be22dae1597d/help-with-a-powershell-script-to-find-and-replace-a-line-of-text?forum=itcg

and this:

http://serverfault.com/questions/475325/replacing-a-line-or-date-in-a-text-file-using-powershell

you'd read file , replace (then can decide if specific lines, replacing or other string manipulation etc).



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Error: 0x80073701 when trying to add Print Services Role in Windows 2012 Standard

Disconnecting from a Windows Server 2012 R2 file sharing session on a Windows 7,8,10 machine

Event ID 64,77,1008 Certificates Events Windows Server 2008, 2008R2