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

  • Home
  • SEARCH
  • 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 7551559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:31:41+00:00 2026-05-30T10:31:41+00:00

I sense that I am doing something silly, but here is the issue: Function

  • 0

I sense that I am doing something silly, but here is the issue:

Function getPropertyOfFile($a, $b, $c)
{
    $a.GetDetailsOf($b, $c)
}

If I pass $a, $b, $c variables that are appropriate to the function, it fails saying that

“Method invocation failed because [System.Object[]] doesn’t contain a method named ‘GetDetailsOf’.”

However, if I directly replace $a, $b, $c with the arguments that I was passing, and then try to run that, it works fine.

What the heck is going on?

Note: I am using powershell ISE, and am inputting the function to powershell by copy/pasting it into the console. I have also been working under the assumption that if I input a new function with the same name, it would overwrite. Is there a better way to just have PS read from the .ps1?

Edit: I am trying to wrap the answer to this question into functions.

Edit 2:

Function getPropertyOfFile $a $b $c
{
    $a.GetDetailsOf($b, $c)
}

Gives an Missing function body in function declaration.
At line:1 char:28
error.

  • 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-30T10:31:43+00:00Added an answer on May 30, 2026 at 10:31 am

    Functions in PowerShell are called similar to cmdlets, so you don’t need to separate arguments with commas.

    Your invocation likely looks like this:

    getPropertyOfFile($foo, $bar, $baz)
    

    which results in $a having the value $foo, $bar, $baz (an array) while $b and $c are $null.

    You need to call it like this:

    getPropertyOfFile $foo $bar $baz
    

    which, as noted, is identical to how you call cmdlets. You could even do

    getPropertyOfFile -a $foo -c $baz -b $bar
    

    at which point you probably notice that your function arguments aren’t named very well 😉

    EDIT: As noted before your declaration of the function is fine. The problem is in the code you didn’t post but is easily inferrable for people with PowerShell experience. Namely, the invocation of your function.

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

Sidebar

Related Questions

I am doing something that is probably silly, but it would be nice if
It makes sense that something like an operating system would be written in C.
I'm probably doing something wrong here because this looks a bit stupid. I'm setting
how would i got about doing something when hovering over a list item, but
I'm probably doing something stupid but I just can't seem to get the permissions
I'm new to JSF and I'm sure I'm doing something stupid, but I've been
It now makes sense that the versions aren't right. I know I am using
Does it make sense that if the Text on a TextBox is databound to
Does it makes sense that when columns of a datagridview are cleared, all rows
'Block' in the sense that the user is shown the Workflow is starting page

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.