Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot validate argument on parameter 'MySiteHostLocation'. The argument is null....

Status
Not open for further replies.

woter324

Technical User
Jan 26, 2007
179
0
0
GB
Hi,
This one's been killing me all week. Thankfully a short week!

This snippet of a script connects to a SharePoint "app" server using PS Remoting and attempts to update the profile photos. Problem is, its telling me that one of the arguments is empty, but I cannot fathom why. Everything I have done to test suggests it has a value.

Code:
function updateSP(){
         $SPServer = ('PLVSSPAPP01','LVVSSPAPP01'),('DOMAIN\SA-SPAdmin-PL','DOMAIN\SA-SPAdmin-L'),('[URL unfurl="true"]http://mysites-pl','http://mysites')[/URL]
	#Iterates through each server in $SPServer array
	for($i=0; $i -lt $SPServer[0].length; $i++) {
		$server = $SPServer[0][$i] 
		$user = $SPServer[1][$i] 
		$mySitesUrl = $SPServer[2][$i]
		
		echo $server $user $Commandline $mySitesUrl
        
        # This Script block is a way of combining multiple commands:
        $myScriptBlock1 = {
            Add-PSSnapin Microsoft.SharePoint.PowerShell
            update-SPProfilePhotoStore -CreateThumbnailsForImportedPhotos 1 -MySiteHostLocation $mySitesUrl
       }
       try{
	$crd = credentials $server $user
	$session = New-PSSession -ComputerName $server -Authentication 'Credssp' -Credential $crd #-AllowRedirection
	Invoke-Command -Session $session -ScriptBlock $myScriptBlock1
	Write-Host "Sharepoint updated on $server, $mySitesUrl."
         Write-Host " "
	Remove-PSSession $Session
       }
       catch{
	$error.clear() 
	Write-Error "Error trying to connect to $server : $error"
       }
		
   }
}

The error:
Code:
Cannot validate argument on parameter 'MySiteHostLocation'. The argument is null. Supply a non-null argument and try the command again.
    + CategoryInfo          : InvalidData: (:) [Update-SPProfilePhotoStore], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Office.Server.UserProfiles.PowerShell.SPCmdletUserProfilePhotoStore

In the echo line, $mySitesUrl (line 9)comes back with the correct value from the array.

If anyone could shed any light on why this script thinks it -MySiteHostLocation is blank I'd be very grateful.

Many thanks

W.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top