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.
The error:
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.
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.