Read from Text file with Powershell
I have a text file that has this data[it represents the name of the device and the user that will logon to it.
Under C: drive of each devices above, there is a text file with a line on it that states:
aaaa bbbbb -username username
I already have a Powershell script "ChangeString.ps1" that can replace the second username by the string that I hardcode inside the powershell command. Actually I have to type in the command the Device name and string that will replace the username.
((Get-Content -Path '\\windows7\c$\test.txt' -Raw) -replace ' username', 'white') | Set-Content -Path '\\windows7\C$\test.txt'
you can notice, in the command above, I have to to enter the name of the device (Windows7) and the string "white" to replace the second username.
That's too much when you have so many devices.
I thought that would help if the powershell command can read from a separate text file that has device name and username and do the replacement on each device.
Any Help ?