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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:44:22+00:00 2026-05-30T08:44:22+00:00

I have a large script which I’m now cleaning up with the use of

  • 0

I have a large script which I’m now cleaning up with the use of functions.
But, I’ve found that it gets kinda messy to put them all at the top of the script.. I have to scroll past hundreds of lines of codes to get to the script itself..

How do you guys keep your scripts tidy? Do you have your functions in a separate file?

  • 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-30T08:44:24+00:00Added an answer on May 30, 2026 at 8:44 am

    Try #Region and #EndRegion

    If you use PowerGUI script editor you can use regions like this:

    #region Set of functions A
    
    function foo {
        Write-Host "Just a function"
    }
    
    function bar {
        return "Just another function"
    }
    
    #endregion
    

    When you open the script in PowerGUI script editor the regions will be collapsed so you don’t have to scroll to get to the main logic. This also works in Microsoft ISE. Not all script editors honor the region tags though.

    Try dot-sourcing or importing as module

    Another way is to externalize your functions either into another script and do what is called dot sourcing . C:\myfunctions.ps1 or put them in a module file named with a .psm1 extension and use Import-Module.

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

Sidebar

Related Questions

I have matlab function that calls a Perl script which converts a large text
I have a very large script which contains a lot of php files, so
I have a SQL script which is extremely large (about 700 megabytes). I am
I have a Perl script which downloads a large number of files from a
I have quite a long script which involves chopping lots of large text files
I have a python script which calls a lot of shell functions. The script
I have a PHP script which reads a large CSV and performs certain actions,
I have a shell script which shuffles a large text file (6 million rows
I have a large database which contains records that have <a> tags in them
I have a large number of pages, each of which use a common header/footer.

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.