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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:35:43+00:00 2026-05-22T20:35:43+00:00

I am building a testing framework for my current development team. One thing that

  • 0

I am building a testing framework for my current development team. One thing that I’d like to let them do is create a Powershell script to run their tests. The system is a database deploy system, so to test it they will need to potentially run some set-up code, then the deploy will be kicked off, then they will run some check code at the end.

Since the deploy takes awhile I’d like to have the framework handle that once for all of the tests. So, the basic flow is:

Run test #1 set-up
Run test #2 set-up
Run test #3 set-up
Run the deploy process
Run the code to confirm that test #1 passed
Run the code to confirm that test #2 passed
Run the code to confirm that test #3 passed

I figured that I would have the framework always call a function called “setup” (or something similar) in all of the Powershell scripts in a particular directory. If no “setup” function exists that’s ok and it shouldn’t error out. Then I would run the deploy and then run the other functions in the Powershell scripts.

Given a directory listing, how could I cycle through each Powershell script and run these functions?

Thanks for any guidance!

  • 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-22T20:35:44+00:00Added an answer on May 22, 2026 at 8:35 pm

    Thanks to Matt’s ideas I was able to come across Invoke-Expression. Ideally I would have liked to use Invoke-Command with the -filepath parameter, which supposedly defaults to running locally. However, there is a bug that requires using the -ComputerName parameter even when running locally. If you use that parameter then it requires remoting to be turned on, even when running on the local computer.

    Here’s the code that I used in my script:

    # Run the setup functions from all of the Powershell test scripts
    foreach ($testPSScript in Get-ChildItem "$testScriptDir\*.ps1") {
        Invoke-Expression "$testPSScript -Setup"
    }
    
    # Do some other stuff
    
    # Run the tests in the Powershell test scripts
    foreach ($testPSScript in Get-ChildItem "$testScriptDir\*.ps1") {
        Invoke-Expression "$testPSScript"
    }
    

    My test script then looked like this:

    param([switch]$Setup = $false)
    
    if ($Setup) {write-host "Setting things up"; return}
    
    Write-Host "Running the tests"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm diving in to iPhone development and I'm building an iPhone app that uses
I'm building a unit testing framework for PHP and I was curious if there
I am building an app in Zend Framework at the moment and testing it
I'm building a regression system ( not unit testing) for some Perl scripts. A
I'm building a test harness for my Delphi 2009 app. Testing the logic is
During the process of building software applications, you would start testing what you have
I'm new to Unit Testing, and I'm only getting into the routine of building
I'm using NUnit for testing back-end. Unit tests are being executed while building (I'm
I was doing my academic project and while building and testing i have put
I am building a Web application. When I am testing it on a simulator,

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.