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

The Archive Base Latest Questions

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

I am just getting started with Windows Powershell and I am try to create

  • 0

I am just getting started with Windows Powershell and I am try to create a function that parses a webpage. I have tested the individual calls in the function and they seem to be working correctly. Here is the function I have created.

function GoTo-Website ([string]website = "google.com")
{
     $ie.navigate($website);

     $image = @($ie.Document.getElementByName("main_image"))[0].href;

     $title = @($ie.Document.getElementByTagName("h1"))[3].innerHTML;

     $date = @($ie.Document.getElementByTagName("h3"))[0].innerHTML;
}

This is stored in powershellScript.ps1 in the current powershell directory.

The best error I can get when I call this function is

function goto-website “Website”

Missing function body in function declaration. At line:1 char:23 + function goto-website <<<< “website” + CategoryInfo : ParserError: (:) [], + FullyQualifiedErrorId : MissingFunctionBody

Is there anyway to modify my code to get pass this parser error?

I also was wondering if their is a way to call a function without putting “function” before the call?

  • 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-31T14:03:31+00:00Added an answer on May 31, 2026 at 2:03 pm

    Try this modified version of your code

    function GoTo-Website
    {
        Param ($website)
        $ie.navigate($website);
        $image = @($ie.Document.getElementByName("main_image"))[0].href;
        $title = @($ie.Document.getElementByTagName("h1"))[3].innerHTML;
        $date = @($ie.Document.getElementByTagName("h3"))[0].innerHTML;
    }
    

    which you can call with

    GoTo-Website "http://www.google.com"
    

    or

    GoTo-Website -website "http://www.google.com/"
    

    No need to put “function” before the call.

    See today’s post on the Scripting Guy Blog for a little more information on functions.

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

Sidebar

Related Questions

So, I'm just getting started with Bazaar. I am using Bazaar explorer for Windows
I'm just getting started with a project that combines GWT, Google App Engine and
I am just getting started on Windows phone 7 development and am stuck at
I'm just getting started with CruiseControl .NET (using the Manning Continuous integration book that
I'm just getting started with Windows Azure Service Bus ( Topics & Queues )
I'm just getting started with Mercurial, downloaded and installed hg command-line for Windows, cloned
Just getting started with C++ here. I am working on OSX with Eclipse CDT.
Just getting started with db2. Quick question about giving it SQL commands from a
Just getting started on NVelocity (v1.1.1) and it seems to be working just fine.
Just getting started building an app using the v6 of the facebook c# sdk

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.