Msdeploy 'computerName' is not recognized as an internal or external command - command-line

Learning TeamCity. Following instructions from https://confluence.jetbrains.com/pages/viewpage.action?pageId=54334902
have wrote such command:
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe"
-source:package="C:\ProgramData\JetBrains\TeamCity\artifacts\webdeploy\Development\<target environment>\TestWebApplication.zip"
-dest:auto,
computerName="https://<windows azure web site web publish URL>:443/msdeploy.axd?site=<windows azure web site name>",
userName="<deployment user name>",
password="<deployment password>",
authtype="Basic",
includeAcls="False"
-verb:sync
-disableLink:AppPoolExtension
-disableLink:ContentExtension
-disableLink:CertificateExtension
as command line build step.
All the parameters have been set in parameters in current build config.
When running build I've got such exception:
The filename, directory name, or volume label syntax is incorrect.
The filename, directory name, or volume label syntax is incorrect.
'computerName' is not recognized as an internal or external command,
operable program or batch file.
'userName' is not recognized as an internal or external command,
operable program or batch file.
'password' is not recognized as an internal or external command,
operable program or batch file.
'authtype' is not recognized as an internal or external command,
operable program or batch file.
'includeAcls' is not recognized as an internal or external command,
operable program or batch file.
The filename, directory name, or volume label syntax is incorrect.
The filename, directory name, or volume label syntax is incorrect.
Process exited with code 1
Step Command Line failed
What am I doing wrong?

A command line should be indeed one line command:
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -source:package="C:\ProgramData\JetBrains\TeamCity\artifacts\webdeploy\Development\<target environment>\TestWebApplication.zip" -dest:auto, computerName="https://<windows azure web site web publish URL>:443/msdeploy.axd?site=<windows azure web site name>", userName="<deployment user name>", password="<deployment password>", authtype="Basic", includeAcls="False" -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension
or, for better readability, escape CR/LF line endings using ^ caret as follows:
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" ^
-source:package='artifacts\WebDeploy\<target environment>\AcmeCompany.Portal.zip' ^
-dest:auto, ^
computerName="https://<windows azure web site web publish URL>:443/msdeploy.axd?site=<windows azure web site name>", ^
userName="<deployment user name>", ^
password="<deployment password>", ^
authtype="Basic", ^
includeAcls="False" ^
-verb:sync ^
-disableLink:AppPoolExtension ^
-disableLink:ContentExtension ^
-disableLink:CertificateExtension ^
-setParamFile:"msdeploy\parameters\<target environment>\AcmeCompany.Portal.SetParameters.xml"
Honestly, I'm not sure about proper quoting -source: argument target if used path would contain space(s):
-source:"package='artifacts\WebDeploy\real target environment\AcmeCompany.Portal.zip'"
and about using ' single quotes (apostrophes):
-source:"package=artifacts\WebDeploy\real target environment\AcmeCompany.Portal.zip"
or
-source:package="artifacts\WebDeploy\real target environment\AcmeCompany.Portal.zip"

Related

Running Azure CLI script in Azure DevOps Pipeline however unable to find the CLI script

param (
$ProjectFilePath= $(Buildin.SourcesDirectory)\TESTREPO7\RuleConfig.json
$ExecutableFilePath= $(Buildin.SourcesDirectory)\TESTREPO7\Studio.zip\Studio\UiPath.Studio.CommandLine.exe
$OutputFilePath= $(Buildin.SourcesDirectory)\$(Get-Date -Format 'yyyy-MM-dd-HH-mm-ss')-Workflow-Analysis.json
)
Write-Output "$(Get-Date -Format 'HH:mm:ss') - STARTED - Workflow Analyzer CLI Script"
$Command = "$ExecutableFilePath analyze -p $ProjectFilePath"
Invoke-Expression $Command | Out-File -FilePath $OutputFilePath
Write-Output "$(Get-Date -Format 'HH:mm:ss') - COMPLETED - Workflow Analyzer CLI Script"
XXXXXXXXXXXXXXXXXXXXXXXXXXXX
Error:
##[section]Starting: Azure CLI UiPathWorkFlow
==============================================================================
Task : Azure CLI
Description : Run Azure CLI commands against an Azure subscription in a Shell script when running on Linux agent or Batch script when running on Windows agent.
Version : 1.152.1
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-cli
==============================================================================
##[error]Script failed with error: Error: Unable to locate executable file: 'C:\agent1\_work\362\s\TESTREPO7\UiPathAnalyze.ps1'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.
##[section]Finishing: Azure CLI UiPathWorkFlow
XXXXXXXXXXXXXXXXXXXX
Very important- When on a local computer, uiath.studio.commandline.exe (workflow analyzer) has rules stored in User directory (%LocalAppData%\UiPath\Rules = C:\Users\User1\AppData\Local\UiPath\Rules). How would I be able to input this information in the script provided above??
Azure CLI latest version installed on azure DevOps agent server.
Tried adding environment parameter but not sure what to enter but this error occurred anyways. Added Environment made did not fix the error.
added both below environmentals—
PATH $(Buildin.SourcesDirectory)\TESTREPO7\UipathAnalyze.ps1
Build.SourcesDirectory $(Buildin.SourcesDirectory)\TESTREPO7\UipathAnalyze.ps1
Check this doc predefined variables, the path should be $(Build.SourcesDirectory) instead of $(Buildin.SourcesDirectory)
The error message is: Unable to locate executable file: 'C:\agent1\_work\362\s\TESTREPO7\UiPathAnalyze.ps1'
The UipathAnalyze.ps1 is the code you shared and it it the Script Path in the task Azure CLI, right? We need open the folder path C:\agent1\_work\362\s\TESTREPO7 to check if the file exists.
In addition, could you successfully run the .ps1 file on the local agent machine?

While creating a cordova app error is powershell is not recognized as an internal or external command, operable program or batch file

So I am creating a cordova app using the command is cordova create TestApp and the error is
Command failed: powershell (Get-CimInstance -ClassName Win32_OperatingSystem).caption
'powershell' is not recognized as an internal or external command,
operable program or batch file. I have also attached the screenshot please take a look at this.
First you should excute the command "powershell",
If fail, config system variable path "C:\Windows\System32\WindowsPowerShell\v1.0".
If your windows System32 folder have no WindowsPowerShell this folder, install powershell and config it to system variable path

How to provide a SAS token to Azure CLI within PowerShell

I'm using the Azure CLI 2.0 from PowerShell to manage a storage account. I have a SAS token (which I am storing in a variable) and I want to use it in a command. Here's the script I'm running:
$sasToken = 'st=2017-11-13T10%3A55%3A06Z&se=2017-11-13T11%3A27%3A06Z&sp=w&spr=https&sv=2017-04-17&sr=c&sig=%2BA6LDTwHes6JdxEAHXSvbYc70y30OcznjMVSyFbCXog%3D'
az storage blob upload `
--account-name mystorageaccount `
--container-name mycontainer `
--file c:\temp\file.txt `
--name file.txt `
--sas-token $sasToken
When I run this, I get this error:
The specified resource does not exist.
'se' is not recognized as an internal or external command,
operable program or batch file.
'sp' is not recognized as an internal or external command,
operable program or batch file.
'spr' is not recognized as an internal or external command,
operable program or batch file.
'sv' is not recognized as an internal or external command,
operable program or batch file.
'sr' is not recognized as an internal or external command,
operable program or batch file.
'sig' is not recognized as an internal or external command,
operable program or batch file.
It appears to me that PowerShell is truncating the SAS token every time it sees an ampersand, and the Azure CLI isn't getting this as all part of the same string.
Is there a way to force PowerShell to call the Azure CLI with the SAS token exactly as-is?
Try wrapping the SAS token in a 2nd set of quotes:
$sasToken = '"st=2017-11-13T10%3A55%3A06Z&se=2017-11-13T11%3A27%3A06Z&sp=w&spr=https&sv=2017-04-17&sr=c&sig=%2BA6LDTwHes6JdxEAHXSvbYc70y30OcznjMVSyFbCXog%3D"'
so that the CLI command looks like this:
--sas-token "st=2017-11-13T10%3A55%3A06Z&se=2017-11-13T11%3A27%3A06Z&sp=w&spr=https&sv=2017-04-17&sr=c&sig=%2BA6LDTwHes6JdxEAHXSvbYc70y30OcznjMVSyFbCXog%3D"
I get the problem this morning and solved the problem like that when SAS Uri is stored in a variable:
$sasUri = "`"$pkgSasUri`""
....
az deployment group create `
--resource-group $rg `
--name create_deployment_cses `
--template-file .\template.json `
--parameters .\parameters.json configurationSasUri=$confSasUri packageSasUri=$pkgSasUri
based on Microsoft devblogs
If you are getting the SAS key from the Azure CLI, do note that if you run it with "-o json" you will get as output the value of the SAS key in quotes. You can directly assign this to a variable and it can be used by the azure CLI without issues (at least, I could place it in an AKV secret)
This is the function I wrote to get that variable as part of my ps1 code:
function Get-SASToken {
param (
# Storage Account
[Parameter(Mandatory=$true)][alias("a")][string]$StorageAccount,
# Storage Container name
[Parameter(Mandatory=$true)][alias("c")][string]$StorageContainer,
# Parameter help description
[Parameter(Mandatory=$true)][alias("p")][string]$SAPolicy
)
echo (az storage container generate-sas --account-name $StorageAccount -n $StorageContainer --policy-name $SAPolicy -o json)
}

Can't submit Data Analytics job in PowerShell Portal

Why can't I run the Submit-AzureRmDataLakeAnalyticsJob cmdlet in a PowerShell runbook via the Aure web portal? I get the following error message:
Submit-AzureRmDataLakeAnalyticsJob : The term 'Submit-AzureRmDataLakeAnalyticsJob' 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 able to run this command with no errors in the PowerShell ISE.
Can this type of command not be run in a runbook or something? Maybe I'm just not understanding PowerShell
I seem to have solved the issue. I had to import some AzureRM.* modules via the Module Gallery on the portal.

MSDeploy Unauthorized Error

I am calling msdeploy using the command line to deploy a web deploy package (zip) to the same machine that I am running the command from.
Here is the command line:
msdeploy.exe -verb:sync -source:package="<pathToZip>" -dest:auto,computerName="<hostName>",includeAcls="False",authType=Basic,userName="<myUserName>",password="<myPassword>" -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:"<pathToSetParametersXml>" -allowUntrusted -preSync:runCommand="<pathToPreDeployCmd",waitattempts=10,waitinterval=30000 -postSync:runCommand="<pathToPostDeployCmd>",waitattempts=5,waitinterval=30000
I've tried this with the msdeploy.axd url, with msdeploy.axd?site url, and with just the host name of the computer. When I run this command on the local machine where it is deploying to, the command fails with an unauthorized exception despite the user being an admin. I ran the same command on a remote computer and it worked when I just used the host name as the ComputerName.
For some reason the same command works remotely but not locally. I copied and pasted the exact command. I've used both the computer host name as well as localhost locally with no luck.
Any ideas on what the problem might be?
Try setting the destination computername to "localhost".