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

The Archive Base Latest Questions

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

I have created a powershell module (.psm1) file that includes a few other powershell

  • 0

I have created a powershell module (.psm1) file that includes a few other powershell scripts. We use it for sharepoint.

So basically, here’s what happens:

  1. I have a deploy script that retrieves the module location from the registry
  2. It loads the module using the Import-Module cmdlet (using -force switch)
  3. This module in turn loads the Sharepoint 2010 snap in and a few other scripts that I created
  4. It runs runs a deployment script that references functions from the included scripts
  5. It also runs a command line application and sends the output directly to the screen

The script will usually work the first time. However, after a few number of tries the commandline tool will stop working and sending output to the screen altogether. And if I try to run a commandline tool (not a cmd-let) after running my script, it don’t worky anymore: no output, nothing is done. Its just the same as hitting enter on a blank prompt. anything powershell specific or running GUI applications will work fine but running any console application will not produce any concievable results. the only solution to this, is to just close my powershell and open it again. it will work for usually once and I will have to close it again. our users certainly wont be happy about that..

The most ‘notable’ things on the script:

  • scriptblocks are used extensively (for logging), a script block is sent to a handler that executes it using invokecommand and logs the step
  • its manipulating sharepoint objects
  • all objects are properly disposed of
  • no static variables are created nor changed
  • There are a few global variables shared across all scripts

What I have tried:
I striped my code to a bare minimum: loading an xml file, and restaring a few windows services but I’m still getting this intermittently. I have no idea which part of the code could cause this. I would love to post the code, but our company policy forbids me to. so my aplogies..

Update as per the comment below:

here’s roughly how I use codeblocks. I have this function below that is used everytime I want to make the user aware of a task that I’m executing and what it outcome is.

function DoTask($someString, $scriptBlock, $param)
{
   try
   {
      OutputTaskDescription $someString
      InvokeCommand $scriptBlock -ArgumentList $param
      OutputResultOK
   }
   catch
   {
      OutputResultError $_.tostring()
   }
}

it could then be used like this:

$stringVar = "something"
$SpSite = new-spsite
deploySomething 'Deploying something' -param $spsite -ScriptBlock {
   dosomethingToObject $stringvar
   dosomethingToObject $spSite.Name
}

it would then output something like:

Deploying Something ------------- OK
Deploying Something ------------- ERROR

Also notice that I pass the $spsite in the argument list and I just use the string directly. I still don’t understand how this works but it seems like I can access all primitive typed variables even without passing them as arguments but I have to pass more complex objects are params, else they dont have any value.

Update:
after much searching and days of pain. I have found others with the same pain. My code exhibits the same exact symptoms as described here:
http://connect.microsoft.com/PowerShell/feedback/details/496326/stability-problem-any-application-run-fails-with-lastexitcode-1073741502

I guess there is no solution yet to this problem.

  • 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-30T21:44:16+00:00Added an answer on May 30, 2026 at 9:44 pm

    After a little while I’ve noticed that if I’ve ran some very memory intensive functions, I too have gotten that behavior where everything you try to execute just goes to the prompt again. I’d recommend setting Set-PsDebug -Trace 2 to see what those functions are actually doing. I fixed my issue by doing this and figuring out how to make my functions more efficient.

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

Sidebar

Related Questions

I have created a few small flash widgets that stream .mp3 audio from an
I am creating NuGet package and for that I have created Nuspec manifest file.
I have created a gui with powershell that allows me to copy files from
We have a powershell script that creates a local html file and the owner
I have a powershell script that is replacing patterns in a file with the
I have created a couple of PowerShell scripts which configure computers used in a
I have an application that I use to run Exchange Powershell commands inside C#
I'm attempting to write a Twitter Powershell script that will use community created interfaces
I have an SSIS file created using the Import and Export wizard. Using that
I have a simple PowerShell script that uses WMI to create a web site

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.