powershell build-in function not recognized as the name of a cmdlet - powershell

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
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.

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.

Related

I'm getting error after installation of mongoDB when I go to windows powershell

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

TerraformApply.jsonOutputVariablesPath : The term 'TerraformApply.jsonOutputVariablesPath' is not recognized as the name of a cmdlet, function

TerraformApply.jsonOutputVariablesPath : The term
'TerraformApply.jsonOutputVariablesPath' 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.
I'm trying to output varaibles via terraform In azure devops but everytime i run pipeline
this happens . P.S i'm using self hosted agent
It's a problem with the version on the task.
I assume you are using V1.
Try using V3 for the apply.
I've opened an issue at
https://github.com/microsoft/azure-pipelines-terraform/issues/83
Edit: I messed up the versions .

Set-Step is not recognised in Powershell script i am using

Set-Step : The term 'Set-Step' 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 above is the error i am facing while running PowerShell script to generate report from grabbing data from source.
Please help me to solve this issue .

Powershell Webjob fails to run

I have created a Powershell Webjob for use in the Azure Logic App. The code is trying to generate a signed URI so the end user can download the file when its available. To do that I created a simple Powershell Webjob.
New-AzureStorageContext : The term 'New-AzureStorageContext' 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.
CommandNotFoundException New-AzureStorageBlobSASToken : The term 'New-AzureStorageBlobSASToken' 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.
I know these are part of the Azure Powershell. But is there an alternative for them to run? Or would I need to resolve to a separate console application?
After a lot of google searching, I found that Azure Powershell jobs do not support Azure commands. They have a plan to allow for that, but currently you cannot run Azure PowerShell Jobs on WebApps Webjob.

Powershell in c# and permissions

I am running PowerShell scripts from a Windows service running as SYSTEM account. To increase rights I am letting users select a user that I later impersonate the whole thread as using LogonUser method.
This works so that I can access network drives and when I try to print the current user in PowerShell that works too.
But I have a case when it does not work:
One example is a user trying to load Exchange snapin and run cmdlet: Get-MailboxPermission
Then he get error: The term 'Get-MailboxPermission' 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 'Get-MailboxPermission' 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.
I am guessing that this is permissions issue and I wonder if there is anything else that needs to be changed to RunSpace etc to get the increased permissions? Any other ideas?
Which PowerShell version?
Looks like you don't have the exchange snapin added. Try running this command before:
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
or, via code, in the runspace initialization, use this code:
RunspaceConfiguration rsConfig = RunspaceConfiguration.Create();
PSSnapInException snapInException = null;
PSSnapInInfo info = rsConfig.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin", out snapInException);
Runspace myRunSpace = RunspaceFactory.CreateRunspace(rsConfig);
myRunSpace.Open(rsConfig);
read this article for additional info:
http://msdn.microsoft.com/en-us/library/exchange/bb332449(v=exchg.80).aspx