2

The term 'Write-Host' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

The term 'New-Object' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again

aka:Write-Host is build-in function in powershell. how to find root cause of that issue?

Update

enter image description here

The same script works while executed in other dev machine.

update

I have tried to set max memory of powershell for single instance to 1GB, and set max memory of powershell for single user to 100M. It still not work.

6
  • > Write-Host hello world it's working fine here. check your spelling and are you in powershell cmd Commented Jan 18, 2016 at 5:36
  • Seems like issues with powershell.exe without enough memory. it really work in my dev machine but not work in production env. Commented Jan 18, 2016 at 5:39
  • What's with all the powershell instances? Why do you need so many? Commented Jan 18, 2016 at 6:49
  • i use powershell in sqlserver agent job. so there are many sqlserver instance and many jobs run at the same time. Commented Jan 18, 2016 at 6:59
  • Just to make sure: if you open a powershell prompt on that machine and execute Write-Host, you get the error message? What do you get if you execute gcm *host*? Commented Jan 18, 2016 at 7:44

1 Answer 1

3

Looks like there is a limit on number shell instances that can be run by a single user. Are you hitting that limit?

Ref: https://msdn.microsoft.com/en-us/library/ee309367(VS.85).aspx

MaxShellsPerUser: The maximum number of shells per user. The default is 30.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks vivek. it works after I remove some silos in our dev environment.
@suiwenfeng, could you please shed more light about how you resolve this problem as i run into the same issue. btw, I didn't see i hit the shell instance etc limits. Thanks !
@KenChen check all powershell processes and kill some of them, avoid over the limitation(MaxShellsPerUser);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.