SOLVED

Cannot bind parameter error message

%3CLINGO-SUB%20id%3D%22lingo-sub-1434113%22%20slang%3D%22en-US%22%3ECannot%20bind%20parameter%20error%20message%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1434113%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20I%20am%20working%20with%20a%20script%20and%20getting%20an%20error%20that%20I%20am%20not%20sure%20how%20to%20deal%20with.%20Script%20snipit%20and%20error%20are%20below.%20My%20Google%20searches%20are%20not%20providing%20any%20help%20and%20any%20help%20is%20greatly%20appreciated!!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%24username%20%3D%20Read-Host%20'Enter%20Username'%0A%24newadmin%20%3D%20Read-Host%20'Enter%20New%20Admin'%0A%24OneDriveUrl%20%3D%20Get-PnPUserProfileProperty%20-Account%20%24username%20%7C%20select%20PersonalUrl%0ASet-SPOUser%20-Site%20%24OneDriveUrl%20-LoginName%20%24newadmin%20-IsSiteCollectionAdmin%20%24True%20-ErrorAction%20SilentlyContinue%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EWhen%20running%20this%20script%20I%20am%20getting%20the%20error....%3CBR%20%2F%3E%3CSTRONG%3ESet-SPOUser%20%3A%20Cannot%20bind%20parameter%20'Site'.%20Cannot%20convert%20the%20%22%40%7BPersonalUrl%3D%3CA%20href%3D%22https%3A%2F%2Fcontoso-my.sharepoint.com%2Fpersonal%2Fprinttest_contoso_com%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fcontoso-my.sharepoint.com%2Fpersonal%2Fprinttest_contoso_com%2F%3C%2FA%3E%7D%22%20value%20of%20type%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E%22Selected.Microsoft.SharePoint.Client.UserProfiles.PersonProperties%22%20to%20type%20%22Microsoft.Online.SharePoint.PowerShell.SpoSitePipeBind%22%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EIm%20not%20sure%20why%20it%20wont%20take%20the%20value%20from%20the%20%24OneDriveUrl%20paramater.%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1434113%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1434220%22%20slang%3D%22en-US%22%3ERe%3A%20Cannot%20bind%20parameter%20error%20message%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1434220%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F531473%22%20target%3D%22_blank%22%3E%40charlie4872%3C%2FA%3E%26nbsp%3BHello%20Charlie%2C%20could%20you%20try%20to%20extract%20the%20URL%20from%20the%20property%3F.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3ESet-SPOUser%20-Site%20%24OneDriveUrl.PersonalUrl%20-LoginName%20%24newadmin%20-IsSiteCollectionAdmin%20%24True%20-ErrorAction%20SilentlyContinue%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3BRegards%3C%2FP%3E%3CP%3EErick%20Moreno%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1434258%22%20slang%3D%22en-US%22%3ERe%3A%20Cannot%20bind%20parameter%20error%20message%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1434258%22%20slang%3D%22en-US%22%3E%3CP%3EYES!!!!!!%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F89674%22%20target%3D%22_blank%22%3E%40Erick%20A.%20Moreno%20R.%3C%2FA%3E%26nbsp%3B%20Thank%20you%20so%20much%20that%20is%20exactly%20what%20I%20was%20looking%20for%20and%20confirmed%20it%20works!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1434284%22%20slang%3D%22en-US%22%3ERe%3A%20Cannot%20bind%20parameter%20error%20message%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1434284%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F531473%22%20target%3D%22_blank%22%3E%40charlie4872%3C%2FA%3E%26nbsp%3BAwesome%2C%20please%20don't%20forget%20to%20mark%20it%20as%20the%20answer.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Contributor

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. 
 

3 Replies
Highlighted
Best Response confirmed by charlie4872 (Contributor)
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

Highlighted

YES!!!!!!@Erick A. Moreno R.  Thank you so much that is exactly what I was looking for and confirmed it works!

Highlighted

@charlie4872 Awesome, please don't forget to mark it as the answer.