SOLVED

Get-PnPSite or Get-PnPWeb error File Not Found

Brass Contributor

I am using this version of PS:
Major Minor Build Revision
-----    -----   -----   --------
5           1      19041    3570

I have also installed PnP for PowerShell.

I am attempting this:

$tenant = "myCompany"
Write-Host "Connecting to https://$($tenant)-admin.sharepoint.com..."
Connect-PnPOnline -Url "https://myCompany-admin.sharepoint.com"
Get-PnPWeb -Identity "https://myCompany.sharepoint.com/sites/mySite"

But I'm getting an error saying:

Get-PnPWeb : File Not Found.
At line:4 char:1
+ Get-PnPWeb -Identity "https://myCompany.sharepoint.com/sites/MyCompan...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-PnPWeb], PSInvalidOperationException
    + FullyQualifiedErrorId : InvalidOperation,PnP.PowerShell.Commands.GetWeb

I've read ALL existing MS documentation and even the PnP docs, but nothing shows how to do it.
My objective is to connect to the tenant (this works) then get a specific site so I can start adding items to it.

5 Replies
Connect-PnPOnline -Url "https://myCompany-admin.sharepoint.com" -Interactive, does that work?
Hi - yes that works but the error comes from
Get-PnPWeb -Identity "https://myCompany.sharepoint.com/sites/mySite"
I get a "File not Found"
Yes, I understand. (Not a SharePoint expert) But you seem to have to connect to the specific site first to use Get-PnPWeb, and I tested that myself. That works. In your case, you should use:
Connect-PnPOnline -Url "https://myCompany.sharepoint.com/sites/mySite"
best response confirmed by CardinalNight (Brass Contributor)
Solution

@CardinalNight Did that work out for you?

Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.

If one of the posts was helpful in other ways, please consider giving it a Like.

This was the answer:
Connect-PnPOnline -Url "https://myCompany.sharepoint.com/sites/mySite"
1 best response

Accepted Solutions
best response confirmed by CardinalNight (Brass Contributor)
Solution

@CardinalNight Did that work out for you?

Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.

If one of the posts was helpful in other ways, please consider giving it a Like.

View solution in original post