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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:19:59+00:00 2026-05-23T10:19:59+00:00

I am creating a powershell module and following the Verb-Noun naming conventions for the

  • 0

I am creating a powershell module and following the Verb-Noun naming conventions for the functions that I exported.

e.g.

function Do-Something() {
    sleep 10
}

Importing the modules works as expected… BUT if I import that module as a custom object.

$myObject = Import-Module MyModule -AsCustomObject

Then try to access the function, I get a parse error:

PS > $myObject.Do-Something()
You must provide a value expression on the right-hand side of the '-' operator.
At line:1 char:22
+ $myObject.Do- <<<< Something()
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : ExpectedValueExpression

I don’t understand. Does this mean that I can’t use the ‘-‘ in methods that belong to objects?
I have noticed that .NET objects and other PSObjects do not have ‘-‘ in their method names.
I haven’t figured out a way to escape it yet either… but even so, that would be messy.

  • 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-05-23T10:19:59+00:00Added an answer on May 23, 2026 at 10:19 am

    Try this:
    $myObject.”Do-Something”()

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

Sidebar

Related Questions

I'm creating a PowerShell script that I'm going to execute using Start-Job . The
I'm creating a custom powershell 1.0 cmdlet that will allow me to feed exceptions
I am creating a number of Powershell cmdlet's and am noticing that after I
I am working on a PowerShell function that is supposed to check if two
I am creating an array of string objects in PowerShell which needs to be
I've created a small script to test creating my own help based powershell and
Creating liquid layouts is an immense pain. Now, I totally understand that tables should
I am creating a new object in a Powershell script, or actually an object
I am creating a string that I would like to pass to the bcp
PowerShell noob question here. I have groups of servers that are listed in separate

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.