none
Scripting to get and set ShowPeoplepickersuggestionsforguestusers RRS feed

  • Question

  • Hello,

    I am trying to create a script that to check and set the following setting ShowPeoplepickersuggestionsforguestusers on SharePoint online.

    single line powershell to get the setting for one site collection.

    Get-SPOSite -Identity "https://test.site.com/Testfeb2018" | select "ShowPeoplepickersuggestionsforguestusers"

    powershell to set

     set-SPOSite -Identity "https://test.site.com/Testfeb2018" -ShowPeoplepickersuggestionsforguestusers $True

    Question:

    How to write a script (possible CSOM), read and enable this setting on a multiple sites? Preferred reading from the csv file.

    This is what I have so far.


    $AdminURI = "https://test.test.com"
    $AdminAccount = "test.test.onmicrosoft.com"
    $site = "C:\test\sites.txt"
    $OutputFileLocation = "C:\scripts\showPeoplepicker-$(get-date -uformat '%Y-%m-%d-%H_%M').txt"
    Connect-SPOService -Url $AdminURI -Credential $AdminAccount
    $reader = [System.IO.File]::OpenText($site)
    try {
        for(;;) {
    # Read a line
            $line = $reader.ReadLine()

    # Stop if it doesn't exist
            if ($line -eq $null) { break }

    Write-Output "One Drive $site" | Out-File $OutputFileLocation -Append 
    Get-SPOSite -Identity $site | select "ShowPeoplepickersuggestionsforguestusers" | Out-File $OutputFileLocation -Append 

        }
    }
    finally {
        $reader.Close()
    }

    Write-Host "Done!"

    Error:

    Get-SPOSite : Cannot bind parameter 'Identity'. Cannot convert value "C:\Scripts\sites.txt" to type
    "Microsoft.Online.SharePoint.PowerShell.SpoSitePipeBind". Error: "SpoSitePipeBind Url"
    At C:\scripts\Get-Sposite-showPeoplepicker.ps1:19 char:23
    + Get-SPOSite -Identity $site | select "ShowPeoplepickersuggestionsforg ...
    +                       ~~~~~
        + CategoryInfo          : InvalidArgument: (:) [Get-SPOSite], ParameterBindingException
        + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Online.SharePoint.PowerShell.GetSite


    mgmjtech

    • Moved by Bill_Stewart Monday, April 30, 2018 9:32 PM Unanswerable drive-by question
    Monday, February 26, 2018 8:58 PM

All replies