Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

using something else in place for "-file"

$
0
0

Hello,

I have been using the latest version of Powershell 3.0 and all of my scripts work fine for what I am trying to do. I have recently been informed that I should design my scripts to work on other platforms of powershell. The only problem that is happening is everywhere I have a "-file" parameter at the end of certain things and I want to know if there is another paramter to pass in place instead. For instance I use this script to go through and replace a "9000" with nothing:

$source_folder = "temp.txt"
$dest_folder = "temp.txt"
cd $source_folder
foreach ($file in (dir $source_folder -file)) {
(Get-Content $file.name)|Foreach-Object {
    $_ -replace '9000', '' 
     }

The "-file" in the script throws exceptions everytime another user who does not have powershell is run. Showing it does not recognize it.

Is there any way to bypass this?Or Replace the "-file" with something else?

Thanks!


Viewing all articles
Browse latest Browse all 8583

Latest Images

Trending Articles



Latest Images