0

We recently began using a load balancer to force HTTPS on our SharePoint, and the PowerShell code below can no longer find the site. I've tried using both https://mysite and //mysite, with the same results.

    [void][System.reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
    $site    =     new-Object Microsoft.SharePoint.SPSite("http://mysite")
    $web     =    $site.rootweb
    $list    =    $web.Lists["mylist"]
5
  • Are you able to navigate to your site using your browser? Commented Feb 5, 2019 at 14:43
  • Yes. I also included the http address in Alternate Access Mappings in Central Admin. Commented Feb 5, 2019 at 15:33
  • Clarification - I can get to the site using the browser on my own computer. When I connect remotely to the server, and visit the site using the server's browser, it asks for credentials. Commented Feb 5, 2019 at 16:04
  • So what error you are getting? does the account that PS runs can log in to site? Commented Feb 6, 2019 at 8:51
  • The error message says the web application cannot be found. Commented Feb 6, 2019 at 12:52

2 Answers 2

0

Check if you can ping this site proper, otherwise create record in HOST file, do ipconfig /flushdns and try access with Internet Browser on Server. You can also try $wa = Get-SPWebApplication and list all Sites Here $wa.Sites if its listed here.

14
  • Thanks. I tried it and got the message "The local farm is not accessible." Commented Feb 6, 2019 at 12:56
  • So you havent set Permissions for running scripts, you need to have SPShellAdmin docs.microsoft.com/en-us/powershell/module/sharepoint-server/… and be in part of Farm Administrator group Commented Feb 6, 2019 at 12:58
  • That produces the error "cannot access the local farm," which doesn't make sense since I'm using the farm account. I'm running PowerShell ISE as an admin. Commented Feb 6, 2019 at 13:17
  • Are you running script on proper SP server? Can you open Farm Administration? Commented Feb 6, 2019 at 13:18
  • Do you mean Central Admin? When the other admin accounts were removed, I lost the icons that were saved in the taskbar. I can get to Central Admin by going through IIS and loading "localhost" followed by the port number, but that's separate from the Central Admin for the site itself. Commented Feb 6, 2019 at 13:37
0

Thanks for all your help. We were able to fix the farm account's permissions by logging in with an admin account.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.