Sunday, 19 April 2015

Unable to browse Sharepoint site on Server

Today I ran some adware removal tool on my SharePoint development server and after that I was not able to access SharePoint site from Server. But the SharePoint Sites worked fine when I accessed it from other computers.

I was able to access sharepoint server sp2013 only from .\Administrator account but non from other accounts.. I did some searching and tried all things but the following script I found might help any one.

The following powershell script basically changes the registry , host file and other places , You just need to run the script  and restart the computer.

#Make backup copy of the Hosts file with today's date
$hostsfile = 'C:\Windows\System32\drivers\etc\hosts'
$date = Get-Date -UFormat "%y%m%d%H%M%S"
$filecopy = $hostsfile + '.' + $date + '.copy'
Copy-Item $hostsfile -Destination $filecopy
# Get a list of the AAMs and weed out the duplicates
$hosts = Get-SPAlternateURL | ForEach-Object {$_.incomingurl.replace("https://","").replace("http://","")} | where-Object { $_.tostring() -notlike "*:*" } | Select-Object -Unique
 
# Get the contents of the Hosts file
$file = Get-Content $hostsfile
$file = $file | Out-String
# write the AAMs to the hosts file, unless they already exist.
$hosts | ForEach-Object { if ($file.contains($_))
{Write-Host "Entry for $_ already exists. Skipping"} else
{Write-host "Adding entry for $_" ; add-content -path $hostsfile -value "127.0.0.1 `t $_ " }}
# Disable the loopback check, since everything we just did will fail if it's enabled
New-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa -Name "DisableLoopbackCheck" -Value "1" -PropertyType dword

No comments :

Post a Comment