[Webinar] Learn how to a build a cloud-first strategyRegister Now


Why is my Powershell command not working?

Posted on 2009-04-16
Medium Priority
Last Modified: 2012-06-27
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

Question by:loftyworm
LVL 18

Accepted Solution

Learnctx earned 2000 total points
ID: 24164513
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.
LVL 11

Author Comment

ID: 24189940
Thank YOU :)

Featured Post

New Tabletop Appliances Blow Competitors Away!

WatchGuard’s new T15, T35 and T55 tabletop UTMs provide the highest-performing security inspection in their class, allowing users at small offices, home offices and distributed enterprises to experience blazing-fast Internet speeds without sacrificing enterprise-grade security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
The viewer will learn how to dynamically set the form action using jQuery.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses
Course of the Month20 days, 12 hours left to enroll

865 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question