Jun 02 2020 11:15 AM
Hello I am working with a script and getting an error that I am not sure how to deal with. Script snipit and error are below. My Google searches are not providing any help and any help is greatly appreciated!!
$username = Read-Host 'Enter Username'
$newadmin = Read-Host 'Enter New Admin'
$OneDriveUrl = Get-PnPUserProfileProperty -Account $username | select PersonalUrl
Set-SPOUser -Site $OneDriveUrl -LoginName $newadmin -IsSiteCollectionAdmin $True -ErrorAction SilentlyContinue
When running this script I am getting the error....
Set-SPOUser : Cannot bind parameter 'Site'. Cannot convert the "@{PersonalUrl=https://contoso-my.sharepoint.com/personal/printtest_contoso_com/}" value of type
"Selected.Microsoft.SharePoint.Client.UserProfiles.PersonProperties" to type "Microsoft.Online.SharePoint.PowerShell.SpoSitePipeBind"
Im not sure why it wont take the value from the $OneDriveUrl paramater.
Jun 02 2020 11:47 AM
Solution@charlie4872 Hello Charlie, could you try to extract the URL from the property?.
Set-SPOUser -Site $OneDriveUrl.PersonalUrl -LoginName $newadmin -IsSiteCollectionAdmin $True -ErrorAction SilentlyContinue
Regards
Erick Moreno
Jun 02 2020 12:00 PM
YES!!!!!!@Erick A. Moreno R. Thank you so much that is exactly what I was looking for and confirmed it works!
Jun 02 2020 12:11 PM
@charlie4872 Awesome, please don't forget to mark it as the answer.
Jun 02 2020 11:47 AM
Solution@charlie4872 Hello Charlie, could you try to extract the URL from the property?.
Set-SPOUser -Site $OneDriveUrl.PersonalUrl -LoginName $newadmin -IsSiteCollectionAdmin $True -ErrorAction SilentlyContinue
Regards
Erick Moreno