Why is my Powershell command not working?

I want to search all the files, and replace a text with another piece of text;

PS C:\temp> dir *.rdp |foreach -process {(Get-Content $_.file) -replace ".edu", '.edu /admin' |set-content $_.file}
Get-Content : Cannot bind argument to parameter 'Path' because it is null.
At line:1 char:42

Open in new window

LVL 11
Who is Participating?
Instead of $_.File use $_.Name or $_.FullName. $_.File isn't a valid property which is why the Get-Content cmdlet can't find a valid path.
loftywormAuthor Commented:
Thank YOU :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.