I wrote this script to help me be able to quickly run up a new auto installed DNN site from a zip file. Check it out and please use yourself. Remember that your Powershell host has to run as Administrator.
#cd "C:\DotNetNuke\ProReleases"
cd "C:\DotNetNuke\Releases"
$CurrentLocation=get-location
#$CEorPE ="Professional"
$CEorPE ="Community"
$version="050400"
$ZipFile = "$CurrentLocation\5.4.0\DotNetNuke_Community_5.4.0.94_Install.zip"
$websiteName = "DotNetNuke" + $CEorPE + $version + "Install"
$websiteAddress = "DotNetNuke" + $CEorPE + $version + ".Install"
$dbname = "DotNetNuke" + $CEorPE + $version + "Install"
$physicalPath = "DotNetNuke" + $CEorPE + $version + "Install"
#remove existing IIS Site and App pool
Import-Module WebAdministration
Remove-Item iis:\Sites\$websiteName -Recurse
Remove-Item IIS:\AppPools\DotNetNukeAppPool -Recurse
$shell=new-object -com shell.application
$CurrentPath=$CurrentLocation.path
$OutPutPath = "$CurrentPath\$physicalPath"
$OutPutLocation=$shell.namespace($OutPutPath)
#delete anything in the destination folder
new-item —force -path $OutPutPath -itemtype "directory"
get-childitem $OutPutPath | remove-item -force -recurse
$ZipFolder = $shell.namespace($ZipFile)
$OutPutLocation.Copyhere($ZipFolder.items())
#Set the ACL on the folder
$acl = Get-Acl $OutPutPath
$permission = "NETWORK SERVICE","FullControl","Allow"
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
$acl.SetAccessRule($accessRule)
Get-ChildItem $OutPutPath -Recurse -Force | Set-Acl -AclObject $acl
#Create the IIS Site
New-Item IIS:\AppPools\DotNetNukeAppPool -Force
Set-ItemProperty IIS:\AppPools\DotNetNukeAppPool -name ProcessModel.identityType -Value 2
New-Item iis:\Sites\$websiteName -bindings @{protocol="http";bindingInformation=":80:$websiteAddress"} -physicalPath $OutPutPath
Set-ItemProperty IIS:\Sites\$websiteName -name applicationPool -value DotNetNukeAppPool
#Update the hosts file
$hostsentry = Select-String $Env:SystemRoot\System32\drivers\etc\hosts -pattern "$websiteAddress" -quiet
if (-not $hostsentry)
{
Add-Content $Env:SystemRoot\System32\drivers\etc\hosts "127.0.0.1 $websiteAddress"
}
#Now open IE and navigate to the site
$ie = new-object -com "InternetExplorer.Application"
$ie.Visible = $true
$ie.Navigate("http://$websiteAddress/")
#some of the code below from http://msdn.microsoft.com/en-us/magazine/cc337896.aspx
$wait = $true
$numWaits = 0
while ($wait -and $numWaits -lt 100) {
$numWaits++
[System.Threading.Thread]::Sleep(500)
$doc = $ie.Document
if ($doc -ne $null) {
$wait = $false
}
else {
write-host "Waiting for app to respond $numWaits . . ."
}
}
if ($numWaits -eq 100) {
throw "Application did not respond after 100 delays"
}
else {
write-host "Application has responded"
}
$auto = $doc.getElementByID("wizInstall_rblInstall_2")
$auto.checked = $true
$nextBtn = $doc.getElementByID("wizInstall_StartNavigationTemplateContainerID_StartNextLinkButton")
$nextBtn.click()
[System.Threading.Thread]::Sleep(60000)
$ie.Navigate("http://$websiteAddress/default.aspx")