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.

    $site    =     new-Object Microsoft.SharePoint.SPSite("http://mysite")
    $web     =    $site.rootweb
    $list    =    $web.Lists["mylist"]
  • Are you able to navigate to your site using your browser? – Marcelo Espinosa Feb 5 '19 at 14:43
  • Yes. I also included the http address in Alternate Access Mappings in Central Admin. – carston1998 Feb 5 '19 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. – carston1998 Feb 5 '19 at 16:04
  • So what error you are getting? does the account that PS runs can log in to site? – Marek Sarad Feb 6 '19 at 8:51
  • The error message says the web application cannot be found. – carston1998 Feb 6 '19 at 12:52

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.

| improve this answer | |
  • Thanks. I tried it and got the message "The local farm is not accessible." – carston1998 Feb 6 '19 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 – Zdeněk Vinduška Feb 6 '19 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. – carston1998 Feb 6 '19 at 13:17
  • Are you running script on proper SP server? Can you open Farm Administration? – Zdeněk Vinduška Feb 6 '19 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. – carston1998 Feb 6 '19 at 13:37

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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