icacls Powershell script, Powershell - IIS .
, Powershell script . CMD BAT , Powershell script.
CMD:
PowerShell -ExecutionPolicy Unrestricted .\Setup.ps1 >> %TEMP%\Setup-DebugLog.txt 2>&1
exit /B 0
Powershell script Setup-DebugLog.txt. , CMD OK Windows Azure, Azure , script .
Powershell script, App_Data:
Import-Module WebAdministration
cd IIS:\Sites
$dir = Get-ChildItem
$timeout = 0
while ($dir -eq $NULL -and $timeout -lt 11)
{
"IIS Site not ready. Waiting for 2 seconds..."
[System.Threading.Thread]::Sleep(2000)
$timeout++
$dir = Get-ChildItem
}
if ($dir -eq $NULL)
{
"IIS Site still not ready. Aborting."
}
else
{
"IIS site ready."
Set-Location $dir.physicalPath
"Location is $($dir.physicalPath)"
$acl = (Get-Item App_Data).GetAccessControl("Access")
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule("Network Service", "Modify, Write", "ContainerInherit, ObjectInherit", "None", "Allow")
$acl.AddAccessRule($rule)
Set-Acl App_Data $acl
"Permission added."
}
WebAdministration, Powershell IIS. -. . , - IIS. , . , -, - , 2 , . 20 , .
- , , ACL App_Data FileSystemAccessRule. , .
, script , IIS 1 . -, script , .
, XML, ServiceDefinition.csdef:
<Startup>
<Task commandLine="Setup.cmd" executionContext="elevated" taskType="background" />
</Startup>
Setup.cmd Setup.ps1 -. , -, , commandLine Task "Subfolder\Setup.cmd", Powershell CMD:
PowerShell -ExecutionPolicy Unrestricted .\Subfolder\Setup.ps1 >> %TEMP%\Setup-DebugLog.txt 2>&1
Also note that there are some differences in calling the Powershell script between Powershell v1 and v2. If I remember correctly, Windows 2008 on Windows Azure launches Powershell v1, and Windows 2008 R2 and later Powershell v2. So, if you are using Windows 2008 on Azure, you will need to change the line that calls the Powershell script, as there is some difference in setting the execution policy.