One of the greatest capabilities of SharePoint 2010 is the ability to install on a client operating system like Windows 7 64-bit. This is a real plus for developers as we previously had to stand up a virtual machine running Windows Server operating system just to be able to develop for SharePoint. More information on how to do this can be found in the MSDN article. There is also an automated PowerShell install script available.
Once one gets SharePoint running on your computer, likely the next roadblock will be trying to figure out how to host a site like http://portal.company.com to run on their system. The first two problems with this scenario is that…
- I do not have access or the authority to add hosts to the corporate DNS. The way around this is to specify the IP and domain name in the C:\Windows\System32\drivers\etc\hosts file.
- IIS is designed to reject traffic from an external domain being routed back to the local computer. The resolution to this is outlined in the KB 896861 Article. Although one of the resolutions is to disable the loopback check, I prefer to specify the Domain Names to be allowed explicitly.
The good news is that we can automate all of the above with a simple PowerShell script that checks the hosts file and adds an entry if needed, then checks the registry value for the BackConnectionHostNames and adds this one if necessary.
param([String]$DN)
Function New-FQDN([String]$DN)
{
Append-UrlToHostsFile -Url $DN
Append-UrlToBackConnectionHostNames -Url $DN
}
Function Append-UrlToHostsFile([String]$Url)
{
if((Get-Content $env:windir\System32\drivers\etc\hosts |?{$_ -imatch "\s$Url"}) -eq $null)
{
"`r`n# Added automagically by the New-FQDN PowerShell Script`r`n::1 $url" | Out-File -FilePath "$env:windir\System32\drivers\etc\hosts" -Append -Encoding ascii
}
}
Function Append-UrlToBackConnectionHostNames([String]$Url)
{
if(($gchn = Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0\" -Name "BackConnectionHostNames" -ea SilentlyContinue) -eq $null)
{
New-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0\" -PropertyType MultiString -Value $Url -Name "BackConnectionHostNames" }
else
{
if(($gchn.BackConnectionHostNames |?{$_ -imatch $Url}) -eq $null)
{
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0\" -Name "BackConnectionHostNames" -Value ($gchn.BackConnectionHostNames+"`n$Url")
}
}
}
if($DN)
{
New-FQDN -DN $DN
}
else
{
Write-Host "Please enter the domain name e.g.
.\New-FQDN.ps1 -DN sub.domain.com"
}
Copy the above script to notepad or some other text editor and save it as New-FQDN.ps1. Then you can execute it via PowerShell in the following manner.
.\New-FQDN.ps1 -DN portal.company.com
My Sisters’ Blog