get warning WARNING: Parameter 'Web' is obsolete. The -Web parameter will be removed in a future

Contributor

hi, 

While using a pnp script I got a warning as below. Can you advise how to remove the warning

 

WARNING: Parameter 'Web' is obsolete. The -Web parameter will be removed in a future release. 

 

Audi86_0-1666218330099.png

 

 

thanks

3 Replies

@Audi86 

 

Add the WarningAction parameter to your Set-PnPGroupPermissions statement.

 

-WarningAction:SilentlyContinue

 

If that doesn't work for this particular command, you can pipe the warning stream (using 3>) to $null:

 

Set-PnPGroupPermission -blah -blah 3> $null;

 

Cheers,

Lain

hi @LainRobertson here is my code, can yo guide me with respect to that? I am trying to add an existing sharepoint group to all subsites under site collection

$SiteURL = "https://abc.sharepoint.com/sites/MyProject"


$Cred = Get-Credential

Try {

Connect-PnPOnline -Url $SiteURL -Credentials $Cred


$subwebs = Get-PnPSubWeb -Recurse

foreach ($Subweb in $subwebs)
{
Write-Host $Subweb.Url
$Answer = Read-Host -Prompt "Do you want to continue adding group to subsites (y or n or break)?"
if ($Answer -eq "n")
{
Continue
}
if ($Answer -eq "break")
{
break
}
Add-PnPGroup -Identity 'PMO Team' -web $Subweb -AddRole Read


}
}
catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}

@Audi86 

 

Unfortunately, I don't work with SharePoint at all meaning I can't troubleshoot SharePoint-related scripts beyond the parts relating specifically to PowerShell (i.e. I can't look at SharePoint errors or why SharePoint isn't doing something it should, etc.)

 

There's a couple of other contributors in this channel who do work extensively with SharePoint though, so hopefully they can stop by and offer some assistance.

 

Cheers,

Lain