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 8494103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:12:27+00:00 2026-06-10T23:12:27+00:00

I am writing PS script that will be integrated with the C# based Windows

  • 0

I am writing PS script that will be integrated with the C# based Windows Form Application. This is what I have tried/done already:

  1. I am able to run PS scripts through the runspace and pipeline, however i encounter the error while I am trying to run the script that uses functions, saying: ” Cannot invoke this function because the current host does not implement it.”

  2. I have researched the problem and I have found very few people who had encoutered similar problem, however one of the solutions underlined that I need to use (add) the following $ConfirmPreference = “None”, ,-Confirm:$false, -Force

  3. However when I tried that the following error message appeared: ” Missing expression after unary operator ‘-‘. “ You can see that I have tried to concatenate the strings by assigning them to the variables, but that did not help. I do not have any idea how to solve it, has anyone got any ideas? Any help will be much appreciated.

       // create Powershell runspace
       Runspace runspace = RunspaceFactory.CreateRunspace();
       // open it
       runspace.Open();
    
       // create a pipeline and feed it the script text
       Pipeline pipeline = runspace.CreatePipeline();
    
       //allow the functions to be exec
       string sa = "$ConfirmPreference = \"None\" ";
       string se = " -Confirm:$false -Force";
       string s = sa +scriptText + se;
       pipeline.Commands.AddScript(s);
    
  • 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-10T23:12:29+00:00Added an answer on June 10, 2026 at 11:12 pm

    -Confirm:$false -Force are meant to be function parameters, they don’t exist on their own.

    Do-Something -param1 'foo' -Confirm:$false -Force
    

    But even if you modify every function call with these parameters, it probably won’t solve all of your issues. See here for more options.

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

Sidebar

Related Questions

I'm writing a script that will ping my ip range. Here's what I have
I'm currently writing a Java daemon. I'm writing a script that will have the
Howdy, I'm writing a batch script that will run on a Windows XP machine.
I'm writing a Python script that will automatically logon users from a list. This
I am writing a script that will take some form data and present it
I am writing a CGI script that will process form data, and it should
I have a problem writing a script that will prevent default behavior of submit
I'm writing a script that will constantly scan iTunes for new dialog boxes and
I am writing a script that will look in a custom reports directory, copy
I'm writing a perl script that will access a MySQL database to determine whether

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.