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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:29:52+00:00 2026-05-11T13:29:52+00:00

Is their anyway to test the correctness of a powershell script without executing it.

  • 0

Is their anyway to test the correctness of a powershell script without executing it. I know you could do something similar in unix, but can’t find the equiv for powershell.

Essentially what I have is a script repository, where each script is tied to rule. If a rule fires, the script executes, but I need to be sure the script is valid, before its put in the repository.

Thanks.

Hi, Well, Unfortunately the -whatif command is not sufficient. Its the syntax of scripts I want to check from a C# runtime engine, which fires a script if a engine rule fires. Before the script fires, I write into it, IList values from the rule, and then I fire it. But I need to ensure it is syntactically correct, otherwise I’m going to have to rely on the rule writer to ensure they are correct, which I can’t do, as many people will wrote rules, only one duff script will bring the engine down. I can’t do that as the engine is an enterpise class product designed for six sigma uptime.

I think the way to do it is to use this, which is a v2 lib.

http://msdn.microsoft.com/en-us/library/system.management.automation.parseexception(VS.85).aspx

I think there is way of creating a ScriptBlock and putting a try catch around it to catch the ParseException. Can somebody tell me how to do it. This is becoming a real challenge.

Thanks.

Hey, Well I spoke to a guy in MS (he’s sharepoint pm) and he spoke to one of the powershell guys, and he informed me that there is no real way in powershell v1 to check the syntax of the script without executing. So I guess the -whatif flag is the closest, but it not a static checker unfortumately. Good news is, in v2 there is a way to tokenize the input stream, via the Automation.PsParser class, Tokenize member. This will tokenize a script in accordance with the PS grammes, so if it craps out, its a crap script. Question is v2 doesn’t have an release date as yet.

Thanks for help. Bob.

  • 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. 2026-05-11T13:29:53+00:00Added an answer on May 11, 2026 at 1:29 pm

    The thing you want is prolly whatif / confirm. Its direct port from Unix world.

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

Sidebar

Ask A Question

Stats

  • Questions 90k
  • Answers 90k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you are using SharePoint Designer to do this, take… May 11, 2026 at 6:00 pm
  • Editorial Team
    Editorial Team added an answer I have the solution for this problem. When an element… May 11, 2026 at 6:00 pm
  • Editorial Team
    Editorial Team added an answer You have two options for table cells: TD or TH.… May 11, 2026 at 6:00 pm

Related Questions

Ok I have two modules, each containing a class, the problem is their classes
The documentation provides a succinct example, and one that looks like it's missing a
I'm looping through the Session keys and adding entries and their values to a
I am attempting to POST against a vendor's server using PHP 5.2 with cURL.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.