pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
987 stars 665 forks source link

Get-PnPAlert Documentation for the List Parameter isnt accurate #2423

Open nate1178 opened 4 years ago

nate1178 commented 4 years ago

Notice: many issues / bugs reported are actually related to the PnP Core Library which is used behind the scenes. Consider carefully where to report an issue:

  1. Are you using Apply-SPOProvisioningTemplate or Get-SPOProvisioningTemplate? The issue is most likely related to the Provisioning Engine. The Provisioning engine is not located in the PowerShell repo. Please report the issue here: https://github.com/officedev/PnP-Sites-Core/issues.
  2. Is the issue related to the cmdlet itself, its parameters, the syntax, or do you suspect it is the code of the cmdlet that is causing the issue? Then please continue reporting the issue in this repo.
  3. If you think that the functionality might be related to the underlying libraries that the cmdlet is calling (We realize that might be difficult to determine), please first double check the code of the cmdlet, which can be found here: https://github.com/OfficeDev/PnP-PowerShell/tree/master/Commands. If related to the cmdlet, continue reporting the issue here, otherwise report the issue at https://github.com/officedev/PnP-Sites-Core/issues

Reporting an Issue or Missing Feature

The docuementation states "The ID, Title or Url of the list." but if i provide it a list URL, it returns alert data for all alerts on the site and not just from the list URL that is provided.

Expected behavior

The output expected would be the alerts that users have set on the list based off of the list URL passed in to the cmdlet

Actual behavior

The cmdlet returns all alerts that have been configured on all lists within the site

Steps to reproduce behavior

Please include complete code samples in-line or linked from gists $User = Get-PnPUser -Identity "Some Users Login Name" $Alerts = Get-PnPAlert -List "URL to some list" -User $User $Alerts

Which version of the PnP-PowerShell Cmdlets are you using?

What is the version of the Cmdlet module you are running?

3.13.19... 3.8.1904.0 3.7.1903.0

How did you install the PnP-PowerShell Cmdlets?

ghost commented 4 years ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

danielcecil commented 4 years ago

Hi @nate1178, can you give an example of the list URL you are using? The URL needs to be relative to the web (site) you are using, e.g. lists/testlist rather than the full path. I assume if the list cannot be resolved the command fetches alerts for all lists in the site.

nate1178 commented 4 years ago

Hi @danielcecil If i were to use (https://SomeSite.sharepoint.com/Sites/test/Lists/AlertTest/) in the List parameter, this would return all alerts in the site. If i use (Lists/AlertTest) in the List parameter, it returns only the alerts for this list. However, the documentation states that you can use the ID, Title, or URL of the list. There is no mention in the documentation that says to use the relative list URL. Also, in examples 2 and 3 in the documentation, it only shows the list name and not the relative list URL for the list, making this documentation page a bit confusing

danielcecil commented 4 years ago

Hi @nate1178, in general you don't use the full URL in PnP or CSOM (the underlying library) since when you use the Connect-PnPOnline command the context is set to the site URL, so the URL you need to use should be relative to the site you are connected to.

I agree the examples and documentation are a little confusing. You can also use Get-PnPList to get the list and make sure it's there before running the command, for example:

$list = Get-PnPList "Lists/MyList"
if($list) {
    $alerts = Get-PnPAlert -List $list -User $user
    $alerts
} else {
    Write-Host "List cannot be found"
}