I am getting the error below:
2020-09-17T10:05:00.724 [Error] ERROR: Error logging into WVD: The
term 'Get-AutomationPSCredential' 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.Exception :Type :
Microsoft.PowerShell.Commands.WriteErrorExceptionMessage : Error
logging into WVD: The term 'Get-AutomationPSCredential' 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.HResult :
-2146233087CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorExceptionFullyQualifiedErrorId :
Microsoft.PowerShell.Commands.WriteErrorException,_TimerTrigger1_InvocationInfo
:MyCommand : _TimerTrigger1_HistoryId : 1InvocationName :
_TimerTrigger1_CommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, D:\home\site\wwwroot\TimerTrigger1\run.ps1: line
158Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException : Result:
ERROR: Error logging into WVD: The term 'Get-AutomationPSCredential'
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.Exception
:Type : Microsoft.PowerShell.Commands.WriteErrorExceptionMessage :
Error logging into WVD: The term 'Get-AutomationPSCredential' 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.HResult :
-2146233087CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorExceptionFullyQualifiedErrorId :
Microsoft.PowerShell.Commands.WriteErrorException,_TimerTrigger1_InvocationInfo
:MyCommand : _TimerTrigger1_HistoryId : 1InvocationName :
_TimerTrigger1_CommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, D:\home\site\wwwroot\TimerTrigger1\run.ps1: line
158Exception: Error logging into WVD: The term
'Get-AutomationPSCredential' 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.Stack:
I have seen information online that suggests it is part of the module "AzureAutomationAuthoringToolkit", but I don't understand how I install this into the environment the Function App runs in.stuff and am following a blog post below to try and get the auto-start up shut down working. I am fairly certain that I have followed this correctly. To me the error suggests that the environment doesn't have the module loaded.
https://www.ciraltos.com/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function/
I don't think you can use the command Get-AutomationPSCredential in the azure function, it is an Internal cmdlet belongs to the internal module Orchestrator.AssetManagement.Cmdlets, it is only available when you're executing runbooks in the Azure sandbox environment, or on a Windows Hybrid Runbook Worker.
So in your case, your option is to use the script in the automation powershell runbook, then use Invoke-WebRequest in the timer trigger to invoke the web request to the webhook URL of the runbook to start the runbook(As the script should be ran every 5 mins said by author).
Invoke-WebRequest -Uri <Webhook URI> -Method Post
For more details, you could refer to the link mentioned in the Github repo.
Related
This is the code i have written in my tut63.js file
code
console.log('Hello World');
when i type node tut63.js in terminal it was suppose to show " Hello World ".
But instead it is showing this error in terminal.
code
PS C:\Users\m\Desktop> node.tut63.js
The term 'node.tut63.js' is not recognized as the name of a cmdlet, function, script file, or oper
able program. Check the spelling of the name, or if a path was included, verify that the path is c
orrect and try again.
At line:1 char:14
node.tut63.js <<<<
CategoryInfo : ObjectNotFound: (node.tut63.js:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
Current setup:
Manually launched Windows server 2019 instance with nodes app in AWS.
Below commands are working fine with this instance
Pm2 delete myapp
Pm2 start
Issue :
We have created AMI of the above instance and launched it with a cloudformation template.
In the userdata of cloudformation template, we have made some changes in the config file of nodejs and restarting the nodes app with the above commands.
Output:
config file modified successfully with cloduformation userdata
Error:
The above commands (Pm2 delete myapp and Pm2 start) failed in the execution of userdata. below is the userdata log.
The errors from user scripts: pm2 : The term 'pm2' 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.
At C:\Windows\TEMP\UserScript.ps1:15 char:1
+ pm2 delete RenderWorker
+ ~~~
+ CategoryInfo : ObjectNotFound: (pm2:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
pm2 : The term 'pm2' 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.
At C:\Windows\TEMP\UserScript.ps1:16 char:1
+ pm2 start
+ ~~~
+ CategoryInfo : ObjectNotFound: (pm2:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Other findings:
Pm2 command is available with newly launched ec2 instance.
C:\Users\Administrator>pm2
usage: pm2 [options] <command>
pm2 -h, --help all available commands and options
pm2 examples display pm2 usage examples
pm2 <command> -h help on a specific command
Access pm2 files in ~/.pm2
Userdata in cloudofrmation:
UserData:
Fn::Base64: !Sub |
<powershell>
$config = '{
"MyENV": "${MyENV}",
"UR1L": "${URL1}",
"URL2": "${URL2}",
"BUCKET": "${MyBucket}",
"PATH": "${Mypath}"
}'
echo $config
$config | Set-Content C:\Projects\myapp\settings\config.json
cd 'C:\Projects\myapp'
pm2 delete RenderWorker
pm2 start
</powershell>
<runAsLocalSystem>true</runAsLocalSystem>
<persist>true</persist>
I doubt that you can run pm2 directly like that because the path to pm2 does not exist under SYSTEM path.
You are likely required to include the full path of it as follows to run the command.
For example, your pm2 resides under C:\etc\ then you need to include as follows:
C:\etc\.pm2 delete RenderWorker
C:\etc\.pm2 start
or if you are familiar with the path, you can make it as an environment variable.
Using: Pool: Azure Pipelines ยท Agent: Hosted Agent
First Release contained only 2 tasks:
Powershell inline script which writes "Hello world"
Powershell on Azure subscription inline script which writes "Hello world"
It worked fine.
After I added additional tasks:
Executing our PowerShell script
.4 Deploy to Kubernetes tasks.
Created Release with system.debug and it failed on the first task with an error:
2020-05-20T06:57:10.3710666Z ##[error]The term 'powershell.exe' 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.
Executing with system.debug gave this output:
2020-05-20T07:15:13.9833585Z ##[debug]Evaluating condition for step: 'Hello World'
2020-05-20T07:15:13.9843565Z ##[debug]Evaluating: succeeded()
2020-05-20T07:15:13.9844512Z ##[debug]Evaluating succeeded:
2020-05-20T07:15:13.9845838Z ##[debug]=> True
2020-05-20T07:15:13.9846542Z ##[debug]Result: True
2020-05-20T07:15:13.9847415Z ##[section]Starting: Hello World
2020-05-20T07:15:14.0314856Z ==============================================================================
2020-05-20T07:15:14.0315650Z Task : PowerShell
2020-05-20T07:15:14.0317519Z Description : Run a PowerShell script on Linux, macOS, or Windows
2020-05-20T07:15:14.0317953Z Version : 2.169.0
2020-05-20T07:15:14.0318548Z Author : Microsoft Corporation
2020-05-20T07:15:14.0319259Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
2020-05-20T07:15:14.0319792Z ==============================================================================
2020-05-20T07:15:15.8622679Z ##[debug]VstsTaskSdk 0.11.0 commit 7ff27a3e0bdd6f7b06690ae5f5b63cb84d0f23f4
2020-05-20T07:15:16.0680294Z ##[debug]Entering D:\a\_tasks\PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1\2.169.0\powershell.ps1.
2020-05-20T07:15:16.0782094Z ##[debug]Loading resource strings from: D:\a\_tasks\PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1\2.169.0\task.json
2020-05-20T07:15:16.1340432Z ##[debug]Loaded 11 strings.
2020-05-20T07:15:16.1343861Z ##[debug]SYSTEM_CULTURE: 'en-US'
2020-05-20T07:15:16.1345219Z ##[debug]Loading resource strings from: D:\a\_tasks\PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1\2.169.0\Strings\resources.resjson\en-US\resources.resjson
2020-05-20T07:15:16.1597086Z ##[debug]Loaded 11 strings.
2020-05-20T07:15:16.1959084Z ##[debug]INPUT_ERRORACTIONPREFERENCE: 'stop'
2020-05-20T07:15:16.2027000Z ##[debug]INPUT_FAILONSTDERR: 'false'
2020-05-20T07:15:16.2028272Z ##[debug] Converted to bool: False
2020-05-20T07:15:16.2041964Z ##[debug]INPUT_IGNORELASTEXITCODE: 'false'
2020-05-20T07:15:16.2056755Z ##[debug] Converted to bool: False
2020-05-20T07:15:16.2081737Z ##[debug]INPUT_PWSH: 'false'
2020-05-20T07:15:16.2100091Z ##[debug] Converted to bool: False
2020-05-20T07:15:16.2122826Z ##[debug]INPUT_WORKINGDIRECTORY: 'D:\a\r1\a'
2020-05-20T07:15:16.2247526Z ##[debug]Asserting container path exists: 'D:\a\r1\a'
2020-05-20T07:15:16.2273044Z ##[debug]INPUT_TARGETTYPE: 'inline'
2020-05-20T07:15:16.2307533Z ##[debug]INPUT_SCRIPT: '# Write your PowerShell commands here.
2020-05-20T07:15:16.2320023Z ##[debug]
2020-05-20T07:15:16.2331579Z ##[debug]Write-Host "Hello World"'
2020-05-20T07:15:16.2375904Z Generating script.
2020-05-20T07:15:16.2515233Z ##[debug]AGENT_VERSION: '2.168.2'
2020-05-20T07:15:16.2594226Z ##[debug]AGENT_TEMPDIRECTORY: 'D:\a\_temp'
2020-05-20T07:15:16.2614777Z ##[debug]Asserting container path exists: 'D:\a\_temp'
2020-05-20T07:15:27.6754436Z ##[debug]Leaving D:\a\_tasks\PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1\2.169.0\powershell.ps1.
2020-05-20T07:15:27.9496049Z ##[debug]Caught exception from task script.
2020-05-20T07:15:27.9529115Z ##[debug]Error record:
2020-05-20T07:15:28.0379597Z ##[debug]The term 'powershell.exe' 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.
2020-05-20T07:15:28.0395647Z ##[debug] + CategoryInfo : ObjectNotFound: (powershell.exe:String) [], CommandNotFoundException
2020-05-20T07:15:28.0402331Z ##[debug] + FullyQualifiedErrorId : CommandNotFoundException
2020-05-20T07:15:28.0412871Z ##[debug]
2020-05-20T07:15:28.0433105Z ##[debug]Script stack trace:
2020-05-20T07:15:28.0479363Z ##[debug]
2020-05-20T07:15:28.1031586Z ##[debug]Exception:
2020-05-20T07:15:28.1168338Z ##[debug]System.Management.Automation.CommandNotFoundException: The term 'powershell.exe' 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.
2020-05-20T07:15:28.1325804Z ##[error]The term 'powershell.exe' 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.
2020-05-20T07:15:28.1338779Z ##[debug]Processed: ##vso[task.logissue type=error]The term 'powershell.exe' 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.
2020-05-20T07:15:28.1347561Z ##[debug]Processed: ##vso[task.complete result=Failed]
2020-05-20T07:15:28.2164053Z ##[section]Finishing: Hello World
Note.
Don't name your variable path in the Azure DevOps pipeline, because it will rewrite an environment variable PATH.
After renaming my variable it worked again and was able to find all tools.
In MS documentation it's not mentioned, so I created a ticket for them.
I'm trying to download and run a PowerShell script (from blob storage) using the Run Powershell artifact on an existing VM in Azure DevTest labs.
I get the following error and I assume I am doing something stupid.
& : The term './script.ps1' 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.
At line:1 char:3
+ & ./script.ps1
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (./script.ps1:String) [], Comman
dNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Here is my setup...
I have also tried the JSON array syntax, which gave the same result, and an invalid URL which gave a 404 error so it seems as if it is downloading my script but then failing to find it.
Below is info I wrote a while back.
Few items to note:
Folder structure is not supported as of this writing. Therefore, script needs to be at the root of the container
Ensure your blob is public
First you will need your file in Azure storage. Once uploaded in your container, click the file to get to its properties and copy the URL field.
As an example, I have created the following Run.ps1 script file and uploaded it to storage as a blob:
param ( [string]$drive = "c:\" )
param ( [string]$folderName = "DefaultFolderName" )
New-Item -Path $drive -Name $folderName -ItemType "directory"
Now, while adding the 'Run PowerShell' artifact to the VM, we provide the following information:
File URI(s): URL field copied from earlier step. (eg. https://myblob.blob.core.windows.net/mycontainer/Run.ps1)
Script to Run: Name of the PS1 script, (eg. Run.ps1)
Script Arguments: Arguments as you would write them at the end of your command (eg. -drive "d:\" -folderName "MyFolder")
I am trying to automatically publish all the projects of my .NET solution using the DeplyOnBuild=true argument (according to this answer )
I typed this command in the PowerShell:
msbuild mysolultion.sln /p:Configuration=Debug;DeployOnBuild=true;
But I get the following error message :
The term 'DeployOnBuild=true' 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.
At line:1 char:59
+ msbuild mysolution.sln /p:Configuration=Debug;DeployOnBuild=true <<<< ;
+ CategoryInfo : ObjectNotFound: (DeployOnBuild=true:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I am not sure what I am doing wrong.
PowerShell is interpreting everything after your first semicolon as a separate command.
You need to use quotes:
MSBuild example.sln /p:"Configuration=Debug;DeployOnBuild=true;"
Or use separate /p parameters:
MSBuild example.sln /p:Configuration=Debug /p:DeployOnBuild=true