Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9106855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:26:08+00:00 2026-06-17T02:26:08+00:00

I have a cmdlet with the following defintion: [CmdletBinding(DefaultParameterSetName=Path, SupportsShouldProcess=$TRUE)] param( [parameter(Mandatory=$TRUE,Position=0)] [String] $Pattern,

  • 0

I have a cmdlet with the following defintion:

[CmdletBinding(DefaultParameterSetName="Path",
               SupportsShouldProcess=$TRUE)]
param(
  [parameter(Mandatory=$TRUE,Position=0)]
    [String] $Pattern,
  [parameter(Mandatory=$TRUE,Position=1)]
    [String] [AllowEmptyString()] $Replacement,
  [parameter(Mandatory=$TRUE,ParameterSetName="Path",
    Position=2,ValueFromPipeline=$TRUE)]
    [String[]] $Path,
  [parameter(Mandatory=$TRUE,ParameterSetName="LiteralPath",
    Position=2)]
    [String[]] $LiteralPath,
    [Switch] $CaseSensitive,
    [Switch] $Multiline,
    [Switch] $UnixText,
    [Switch] $Overwrite,
    [Switch] $Force,
    [String] $Encoding="ASCII"
)

I put the cmdlet .ps1 file in the same folder as as a powershell script file that calls the cmdlet as following:

Invoke-Expression -Command .\Replace-FileString.ps1 “9595” “NewPort”
“c:\temp” -Overwrite

However, when I execute my ps script, I get the following error:

Invoke-Expression : A positional parameter cannot be found that
accepts argument ‘9595’.
How can I make it work?
Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T02:26:10+00:00Added an answer on June 17, 2026 at 2:26 am

    Try:

    Invoke-Expression -Command '.\Replace-FileString.ps1 "9595" "NewPort" "c:\temp" -Overwrite'
    

    Your command includes arguments that uses quotemarks, so PS thinks that your command is over and those are new arguments(not a part of the -Command paramter).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code. function createZip { Param ([String]$source, [String]$zipfile) Process { echo
I have this PowerShell cmdlet: function Test-ParameterBinding { # # .SYNOPSIS # Tests parameter
In PowerShell 1.0, if I have a cmdlet parameter of an enum type, what
I have a powershell cmdlet, and I can't seem to get the parameter sets
Is there any restriction to the number of parameter sets a cmdlet can have?
I have a custom cmdlet that can be called like this: Get-Info .\somefile.txt My
I have developed a custom c# cmdlet. It has three parameters (all of them
In PowerShell you can use the Get-WmiObject cmdlet to grab WMI classes. I have
What I have found is that when I write the following function: function test
I have a powershell cmdlet written in C# (deriving from PSCmdlet ) which will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.