0

I have added a new property : "Edit notification and activity stream settings". using power shell

I want to give a url as the value of this property. How to achieve this? When I give the url in the description field it comes below the text box of the property which is not what I need.

0

Feeling stupid ! After a few trials i got the script to update the property value. Here it is

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server") 
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.UserProfiles") 
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
#############################################

write-host "======== Set URL for Notification Settings =========" 

##########CODE########################
# Load SharePoint.PowerShell snapin 
if (!(Get-PSSnapin | ?{$_.name -eq 'Microsoft.SharePoint.PowerShell'})) 
{ 
    if(Get-PSSnapin -registered | ?{$_.name -eq 'Microsoft.SharePoint.PowerShell'}) 
    { 
        Add-PSSnapin Microsoft.SharePoint.PowerShell 
        write-host "Loading Microsoft.SharePoint.PowerShell in session" 
    } 
    else 
    { 
        write-host "Microsoft.SharePoint.PowerShell is not registered with the system." 
        break 
    } 
} 
else 
{ 
    write-host "Microsoft.SharePoint.PowerShell is already loaded" 
} 

$stackTrace = ""
$ScriptPath = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
$logcsv = $ScriptPath + "\UpdateURL_log.csv"        #output csv format
Set-Content -Path $logcsv -Value $header -Encoding UTF8

#Function to get service context
function Get- SPServiceContext([Microsoft.SharePoint.Administration.SPServiceApplication] $profileApp)
{
 $profileApp = @(Get-SPServiceApplication | ? {$_.TypeName -eq "User Profile Service Application"})[0]
 return [Microsoft.SharePoint.SPServiceContext]::GetContext($profileApp.ServiceApplicationProxyGroup,[Microsoft.SharePoint.SPSiteSubscriptionIdentifier]::Default)
  }

  $serviceContext = Get-SPServiceContext
$profileManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext)

$profiles = $profileManager.GetEnumerator()
$url = "http://someurl"

 Try
{
foreach ($userProfile in $profiles) {
$u = $userProfile.Item("Accountname")
$u = $u.ToString().ToLower()

if($u.StartsWith("abc") -eq $true){
    Write-host "Setting value for: " $u
     "Setting value for: " + $u | Add-Content -Path $logcsv 
    $userProfile["ActivitySettings1"].Value =  $url     
    $userProfile.Commit()
}
}
}
   catch{
     Write-Host -ForegroundColor Red $_.Exception.Source
Write-Host -ForegroundColor Red $_.Exception.Message
Write-Host -ForegroundColor Red $_.Exception.StackTrace
$_.Exception.Source + ";"+ $_.Exception.Message +";" + $_.Exception.StackTrace  | Add-Content -Path $logcsv
}
write-host "-------------- Finished Script --------------"
|improve this answer|||||
  • Just curious, why do you need that? – Matthew McDermott Aug 13 '15 at 12:38
  • The requirement is to show a url for a property"Edit your NG settings";which again is a custom property. The user can navigate to the url and edit the settings. – Deepika Aug 14 '15 at 7:28
  • Can't they do that by just editing their profile? Why do you need the URL? – Matthew McDermott Aug 15 '15 at 2:12
  • actually, for a property the value should be a url which should redirect the user to another page which contains another set of news gator properties(a 3rd party pluglin). That url would be same for every user, just a query string:ngSetting=1 appened to the edit profile url – Deepika Aug 18 '15 at 13:37
  • So, if it's the same URL, couldn't you just add the URL to the page? – Matthew McDermott Aug 18 '15 at 14:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.