Why is my Powershell command not working?

Posted on 2009-04-16
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 16

    Accepted Solution

    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

    Thank YOU :)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
    The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now