Hi @Anonymous ,
Welcome to Q&A forum!
This setting is typically configured through the SharePoint web interface by doing the following: Navigate to your Survey >> Click on “Setting” >> Survey Settings >> Click on “List name, description and navigation” >> Set “Allow multiple responses” to “Yes”.
Reference: How to create a survey in SharePoint Online?
Note: Non-official, just for reference.
If you must need to "Enable Multiple Responses" in surveys using Graph API/REST API/PnP PowerShell, indeed as you said, PnP PowerShell is the most viable approach. Since for the Microsoft Graph API and SharePoint REST API, there isn't a direct endpoint to modify the "Allow Multiple Responses" setting for surveys. These APIs primarily focus on CRUD operations for list items and documents.
An InvalidOperation
error suggests there might be issues with the cmdlet usage or the environment setup. Here's how you can approach this:
- Ensure PnP PowerShell Module Compatibility:
- The latest versions of the PnP PowerShell module (2.x and above) require .NET 6 and are compatible only with PowerShell 7 or later. They are not compatible with Windows PowerShell 5.1 or the Integrated Scripting Environment (ISE).
- Authenticate Using the Correct Method:
- For environments with Multi-Factor Authentication (MFA), the
-Interactive
parameter is recommended for authentication.
Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/yoursite" -Interactive
- Verify Survey List Existence and Permissions:
- Ensure that the survey list exists on the specified site and that you have the necessary permissions to modify its settings.
- Implement Error Handling to Capture Detailed Errors:
- Use a try-catch block to capture and analyze any exceptions that occur during the execution:
This approach provides more detailed error information, aiding in troubleshooting. Reference: How to Use PowerShell Try Catch to Handle Errors? Note: Non-official, just for reference.try { $surveyList = Get-PnPList -Identity "YourSurveyListName" $surveyList.EnableMultipleResponses = $true $surveyList.Update() Invoke-PnPQuery } catch { Write-Error "An error occurred: $_" }
- Ensure Proper Cleanup of Connections:
- Not properly disconnecting PnP connections can lead to unexpected errors in subsequent operations. Ensure that you disconnect after completing your operations.
Disconnect-PnPOnline
Hope these information helps.
Please do let us know if you have any further queries.
Kindly consider accepting the answer if the information provided is helpful. This can assist other community members in resolving similar issues.