ARMClient.exe not working in azure powershell workflow (hydrid) - powershell

I am trying to execute the ARMClient.exe from my Azure Powershell Workflow runbook on Hydrid worker.
Its throwing me the folloing error:
Cannot find the 'ARMClient.exe' command. If this command is defined as a workflow, ensure it is defined before the workflow that calls it. If it is a command intended to run directly within Windows PowerShell (or is not available on this system), place it in an InlineScript: 'InlineScript { ARMClient.exe }'
I have followed https://azure.microsoft.com/en-in/blog/leveraging-the-oms-search-api-in-an-azure-automation-runbook/
post step by step.
Can anyone help me resolve this error.
Thanks in Advance!

I restarted the Hybrid worker VM, and it started to recognize the command ARMClient.exe from azure runbook!
Silly of me, I should have restarted the VM before posting the question here :(

Did you do the Hybrid worker setup correctly?
It looks like from the error message that it cannot locate the ARMClient.exe, usually meaning it's not installed / cannot be resolved in the $env:path (paths on the machine).
Did you install chocolatey and the ArmClient package (using choco install armclient) on the worker? Have you verified that the Armclient is installed?
For details installing chocolatey see : https://chocolatey.org/
For details on installing the armclient : https://github.com/projectkudu/ARMClient

Related

vm behind proxy and module installation by pipeline task

A windows vm is configured that is residing the proxy and I can get the response from the VM's admin powershell prompt with the following command:
Get-PSRepository
But if I issue the very same command inside the Azure Devops pipeline I get the following instead:
WARNING: MSG:UnableToDownload «https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409» «»
WARNING: Unable to download the list of available providers. Check your internet connection.
WARNING: Unable to find module repositories.
Finishing: PowerShell
I can check and get the proxy settings though from the powershell in the pipeline with the following command:
netsh winhttp show proxy
I guess you are hosting a self-host agent on the windows VM. Some tools will not automatically use the agent configured proxy settings as stated in the document Run a self-hosted agent behind a web proxy.
You can try setting an environmental variable as below at the beginning of the your powershell command to specifically set the proxy for your powershell task.
$env:http_proxy = "192.3.4.5:8080"
Please refer to this similar thread. If above script to set proxy env variable doesnot work, you can try command Set-InternetProxy -Proxy test:8080 in this blog.

Terraform GCP: Run PowerShell in Windows instance on create

I have made a simple Terraform manifest that successfully initiates a Windows 2016 instance in GCP. As a next step I would like to execute a Powershell script to further configure and install software in the Windows instance.
I can not for my life find any example on how to execute a remote script through Terraform in a Windows GCP instance. For Linux instances it seems pretty straight forward, but how is it supposed to be done for Windows? Does anyone know any examples?
Any thoughts or ideas are much appreciated, thanks!
I had the same situation one month ago in the Oracle cloud. (I think the process is the same for all cloud providers.)
My situation: I have to run the winrm script to allow the communication from ubuntu to windows 2016 server to run the Ansible playbooks.
You can find the answer below.
https://github.com/terraform-providers/terraform-provider-oci/tree/master/examples/compute/windows.
I put my Powershell script (winrm) in the "userdata" folder and update the same in winrm.tf file. That's it.

Internal Server Error in PowerShell cmdlets for Microsoft Dynamics CRM

On Windows Server 2012 Datacenter with Microsoft Dynamics CRM 2016 installed, I want to run a deployment command but for every commands I get this error: "(500) Internal Server Error".
I first run this:
Add-PSSnapin Microsoft.Crm.PowerShell
and it will work fine and when I check it with get-pssnapin and Get-Help *Crm*, every thing is fine and every thing that I need is registered. but when I want to run a cmdlets command like these, I face the error: Get-CrmSetting or Get-CrmCertificate or ...
For example for Get-CrmSetting TraceSettings it give me this error:
How can I solve this problem and error?
Thanks
According to this article, you might want to try:
Get-CrmSetting –SettingType TraceSettings
Here are a couple more items to investigate, from this article:
To use the XRM tooling cmdlets, you need PowerShell version 3.0 or
later. To check the version, open a PowerShell window and run the
following command: $Host
Set the execution policy to run the signed PowerShell scripts. To do
so, open a PowerShell window as an administrator and run the
following command: Set-ExecutionPolicy -ExecutionPolicy AllSigned
Verify the (CRMDeploymentServiceAppPool Application Pool identity) has SQL SEVER SysAdmin permission. This is needed to perform any CRM configuration changes and organizational operations.
Note: it does not matter if the account executing the PowerShell is a system admin or SQL server sysadmin because these operations are executed via the deployment web service.
Deployment Web Service (CRMDeploymentServiceAppPool Application Pool identity)
....Sysadmin permission on the instance of SQL Server to be used for the configuration and organization databases.
....
(500) Internal Server Error, refers to a HTTP response status code. This means that the Powershell command is calling a URL and the URL is reporting a error.
You need to know the URL to really find out what the problem is. One way you can get the URL, is downloading Fiddler Classic. Once installed, you have to enable HTTPS decryption.
In my case the URL was...
https://<my-crm-domain>/XrmDeployment/2011/deployment.svc?wsdl
When I ran this URL on the server where CRM is installed, I got an exception stating...
Could not load file or assembly 'Microsoft.Crm.Application.Components.Application'
All this meant, I needed to copy a file, Microsoft.Crm.Application.Components.Application.dll, from C:\Program Files\Dynamics 365\CRMWeb\bin into folder C:\Program Files\Dynamics 365\CRMWeb\XRMDeployment\bin.
Once this was done, the URL worked and therefor my PowerShell command as well.

TFS Build "PowerShell on Target Machines" Step Fails: How to debug?

I'm trying to automate the deployment of the solution my team is working on through TFS Build server. One of the steps which executes a PowerShell script on the target machine fails with the following error:
Microsoft ODBC Driver 11 for SQL Server : Login failed for user 'sa'..
The PowerShell script I'm trying to execute does in fact connect to multiple databases using the sa credentials. When I try to execute the same script passing it the exact same arguments by hand (i.e: executing the script from the target machine VM itself) it works like a charm. But when it is being executed as part of the build steps it fails with the aforementioned error.
Is there a way to further debug the issue? It would be great if there is a way to output trace statements from the script so I could have some insight on what is actually going on.
Usually all the related error should reflect in TFS build log. To narrow your issue you can try to connect to the TFS build agent with the credentials used for the build service and manually run the ps script.
If you execute the ps script with your own account, which will not help to the issue. Usually this kind of problems is related to permissions. Your build service account are lack of related permission. Try to add it to Administrator or SQL Administrator group and execute the build again.

Setting up a VM for Selenium tests in online TFBuild

EDIT: I overlooked "Prerequisites for executing build definitions is to have your build agent ready, here are steps to setup your build agent, you can find more details in this blog ." from these steps. I'm currently trying to get that build agent up and running on an Azure VM and will report back.
I'm following these steps to try and get CD and Selenium tests running through my Visual Studio Online TFbuild. I've had some helpful hints after sending some feedback via email, but I'm still not able to get past the file copy step.
I've created a Windows 10 Enterprise VM.
I've correctly set the ip address in my build test machines and am able to RDP into the machine.
I've successfully (after several attempts) gotten Remote Power shell working (though I'm not 100% certain winrm s winrm/config/client '#{TrustedHosts="Hosted Agent"}'). I got the name from https://{}.visualstudio.com/DefaultCollection/_admin/_AgentQueue or Build > edit build > General > Default Queue > Manage.
PS C:\users\cdd\Desktop> winrm quickconfig
WinRM service is already running on this machine.
WinRM is already set up for remote management on this computer.
This seems to be ready after
PS remoting is not supported when network connection type is public. Please check http://blogs.msdn.com/b/powershell/archive/2009/04/03/setting-network-location-to-private.aspx.
and echo "setting executionpolicy"
powershell -command "& Set-ExecutionPolicy -executionpolicy unrestricted -force"
echo "setting remoting"
powershell -command "& Enable-PSRemoting -force"
That's a lot of details, but I'm still stuck after that:
Copy started for - '{ip}:5985'
Copy status for machine '{ip}:5985' : 'Failed'
Failed to execute the powershell script. Consult the logs below for details of the error.
Failed to connect to the path \{ip} with the user cdd for copying.System error 53 has occurred.
The network path was not found.
For more info please refer to http://aka.ms/windowsfilecopyreadme
I have a few questions:
Do I have the correct name of the VM?
Do you have steps on how to get the VM setup to allow FileCopy?
I'm probably missing something else, I'm not familiar with PowerShell or getting this setup. What can I try to get the path available for my cdd adminstration user that I setup when I created the VM?
To copy files to an Azure VM machine, you should use the "Azure File Copy" step that provided in VSO build definition. It provides detailed setting for you to access to your Azure VM machine.