1
votes

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.

1
> Write-Host hello world it's working fine here. check your spelling and are you in powershell cmd - Nikson Kanti Paul
Seems like issues with powershell.exe without enough memory. it really work in my dev machine but not work in production env. - suiwenfeng
What's with all the powershell instances? Why do you need so many? - Lieven Keersmaekers
i use powershell in sqlserver agent job. so there are many sqlserver instance and many jobs run at the same time. - suiwenfeng
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*? - Lieven Keersmaekers

1 Answers

3
votes

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.