Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error running PowerShell Commands On Azure WorkerRole

I am trying to run a startup task cmd-script on a Windows Azure Role.

This are the two lines of the command file script:

powershell $command = "set-executionpolicy Unrestricted"    
powershell $command = ".\setupAgent.ps1" -NonInteractive >; out.txt

Now the problem is, I get an error message from the command shell, that says:

D:\Users\UserAccount>powershell $command = "set-executionpolicy Unrestricted"
'powershell' is not recognized as an internal or external command,
operable program or batch file.

It looks like there are used some kind of different codepages or something linke that, because these special chars are not in my cmd file. The cmd-file was created on Windows 8 via VS 2012 Ultimate.

Do you have an idea, how I can dismiss there special chars at the beginning of the command? If I copy the command from the cmd-file to the console via remote desktop it works fine!

like image 952
sebastian87 Avatar asked Apr 08 '13 09:04

sebastian87


People also ask

How do I get specific Azure commands in PowerShell?

Under Azure drive, type Get-AzCommand to get context-specific Azure commands. Alternatively, you can always use Get-Command *az* -Module Az.* to find out the available Azure commands. You can run Install-Module to install modules from the PowerShell Gallery.

What are azure PowerShell jobs?

PowerShell Jobs let you run cmdlets in the background or do multiple tasks on Azure at once, from inside a single PowerShell session. This article is a brief overview of how to run Azure PowerShell cmdlets as PowerShell Jobs and check for completion.

How do I run a PowerShell script on a remote Azure VM?

Run regular PowerShell commands in the Cloud Shell, such as: You can find all your virtual machines under the current subscription via VirtualMachines directory. Please refer to Troubleshooting remote management of Azure VMs. Assuming you have a VM, MyVM1, let's use Invoke-AzVMCommand to invoke a PowerShell script block on the remote machine.

How do I enable debug logging in azure AZ PowerShell?

One of the first steps you should take in troubleshooting a problem with the Azure Az PowerShell module is to enable debug logging. To enable debug logging on a per command basis, specify the Debug parameter. To enable debug logging for an entire PowerShell session, you set the value of the DebugPreference variable to Continue.


1 Answers

Open your whatever.cmd file with your VS 2012 Ultimate. Click on File->Save whatever.cmd as -> on the dialog there is little arrow next to the [save] button. It will show up a menu that will have the option Save with Encoding:

Save With Encoding

Select it. Now choose "US-ASCII Codepage 20127" from the list of available encodings.

like image 138
astaykov Avatar answered Sep 19 '22 04:09

astaykov