Created
June 3, 2015 08:37
-
-
Save pkirch/2261bdc668a19fa9b613 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Warning: This script is only for demo purposes. | |
# The connection to the WebDAV server is not secured. | |
# Content and user credentials are transmitted unencrypted. | |
# Before using this script, you need the PowerShell commandlets installed, have already an Azure | |
# subscription imported and the first three settings in this file changed. (See region Settings.) | |
# How to do this, you can read here (in German): | |
# http://blogs.msdn.com/b/pkirchner/archive/2015/01/13/grundlagen-powershell-f-252-r-microsoft-azure-installieren.aspx | |
# http://blogs.msdn.com/b/pkirchner/archive/2015/01/19/grundlagen-azure-amp-powershell-verwaltungszertifikate-installieren.aspx | |
#region Settings - enter your settings here | |
# Must change: | |
# Your subscription name. | |
$subscriptionName = "MSFT MVA Stage" | |
# Change this service name to a unique name. If the name is not unique, creation will fail. | |
$serviceName = "webdavservertest54191" | |
# Change the path to the Enable-WebDAV.ps1 file. Should be the folder where you unpacked the current file. | |
$scriptFile = New-Object System.IO.FileInfo ("C:\Users\pkirch\OneDrive @ Microsoft\FY15\Content\2014-11-28 New Era Day 3\Enable-WebDAV.ps1") | |
# Can change: | |
$adminUsername = "adm_demo" | |
$adminPassword = "Azureisttoll!" | |
$storageAccountName = $serviceName | |
$vmName = "webdavserver" | |
$instanceSize = "Small" # Get-AzureRoleSize | |
# No need to change: | |
$imageFamily = "Windows Server 2012 R2 Datacenter" | |
$location = "West Europe" # Get-AzureLocation | |
#endregion | |
# In case you have more than one Azure subscription, select one. | |
Select-AzureSubscription -SubscriptionName $subscriptionName | |
# Get latest image for defined image family. | |
$imageName = Get-AzureVMImage | | |
Where-Object -Property ImageFamily -eq $imageFamily | | |
Sort-Object -Property PublishedDate -Descending | | |
Select-Object -ExpandProperty ImageName -First 1 | |
# Create storage account and set is as current. | |
New-AzureStorageAccount -Location $location -StorageAccountName $storageAccountName -Type Standard_LRS | |
Set-AzureSubscription -SubscriptionName $subscriptionName -CurrentStorageAccountName $storageAccountName | |
# Create destination container in storage if it does not exist. | |
New-AzureStorageContainer -Name customscripts -Permission Off -ErrorAction Ignore | |
# Upload PowerShell file | |
Set-AzureStorageBlobContent -Container customscripts -File $scriptFile.FullName -Force | |
# Create new VM configuration, add provisioning data to it, and start it. | |
New-AzureVMConfig -ImageName $imageName -InstanceSize $instanceSize -Name $vmName | | |
Add-AzureProvisioningConfig -Windows -AdminUsername $adminUsername -Password $adminPassword | | |
Add-AzureEndpoint -LocalPort 80 -Name HTTP -Protocol tcp -PublicPort 80 | | |
Add-AzureEndpoint -LocalPort 443 -Name HTTPS -Protocol tcp | | |
Set-AzureVMCustomScriptExtension -ContainerName customscripts -FileName $scriptFile.Name -Run $scriptFile.Name | | |
New-AzureVM -ServiceName $serviceName -Location $location | |
Write-Host "Your action: Map network drive via Windows Explorer to: http://$serviceName.cloudapp.net/" -ForegroundColor DarkGreen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script file has to be executed on the Azure VM. | |
# If you want to automatically create an Azure VM, install IIS and WebDAV | |
# DO NOT execute this file. Instead use the script in file Create-WebDavVm.ps1. | |
# Install IIS. | |
Install-WindowsFeature -Name Web-Server, Web-DAV-Publishing, Web-Windows-Auth, Web-Mgmt-Tools | |
# Configure IIS. | |
Set-WebConfigurationProperty -Filter system.webServer/security/authentication/anonymousAuthentication -PSPath "IIS:\Sites" -Location "Default Web Site" -Name Enabled -Value False | |
Set-WebConfigurationProperty -Filter system.webServer/security/authentication/windowsAuthentication -PSPath "IIS:\Sites" -Location "Default Web Site" -Name Enabled -Value True | |
Set-WebConfigurationProperty -Filter system.webServer/webdav/authoring -PSPath "MACHINE/WEBROOT/APPHOST" -Location "Default Web Site" -Name Enabled -Value True | |
$newRule = @{ | |
users="*" | |
path="*" | |
access="Read, Write, Source" | |
} | |
Add-WebConfiguration -Filter system.webServer/webdav/authoringRules -PSPath "MACHINE/WEBROOT/APPHOST" -Location "Default Web Site" -Value $newRule |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Probably not relevant anymore, but the 'access' property has a mistake: for it to work the values must be comma-separated, but without the additional space.