Error in powershell startup task - Worker Role Azure

I am using the following script inside a .cmd file to unzip a compressed file but for some reason it keeps failing (it does not say in the trace listener).

powershell -command "Set-ExecutionPolicy Unrestricted" 2>> err.out
$(New-Object -com shell.application).namespace('D:\').Copyhere((New-Object -com shell.application).namespace('Dlls\Myzip.zip').items(),0x10)

I dont know much about powershell but this code seemed to work for many people..could you tell me whats wrong about it?

Upvotes: 0

Views: 261

Answers (1)

codingoutloud
codingoutloud

Reputation: 2155

Try setting the executionContext="elevated" attribute when declaring your Startup Task. If unspecified, executionContext="limited" is the default.

For example:

<Startup>
  <Task commandLine="foo.cmd" executionContext="elevated" taskType="simple"/>
</Startup>

From the documentation, this makes sure "the startup task runs with administrator privileges" - which is required to execute that particular PowerShell operation.

Upvotes: 1

Related Questions