Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在UPA sp2010中使用powershell在用户属性中添加节_Powershell_Sharepoint_User Profile - Fatal编程技术网

在UPA sp2010中使用powershell在用户属性中添加节

在UPA sp2010中使用powershell在用户属性中添加节,powershell,sharepoint,user-profile,Powershell,Sharepoint,User Profile,我想使用powershell在UPA中添加节用户属性。我正在执行下面的脚本。它第一次执行,但第二次在ADD方法处出错。此外,属性未被添加 function CreateUserProfileSection() { $site = Get-SPSite $xmlData.UserProfileSection.SiteURL function Get-SPServiceContext([Microsoft.SharePoint.Administration.SPServiceApp

我想使用powershell在UPA中添加节用户属性。我正在执行下面的脚本。它第一次执行,但第二次在ADD方法处出错。此外,属性未被添加

function CreateUserProfileSection()
{     
  $site = Get-SPSite $xmlData.UserProfileSection.SiteURL
  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)
    }
  $context = Get-SPServiceContext  
  $upcm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context);      
  $ppm = $upcm.ProfilePropertyManager
  $cpm = $ppm.GetCoreProperties()
  $ptpm = $ppm.GetProfileTypeProperties([Microsoft.Office.Server.UserProfiles.ProfileType]::User)
  $psm = [Microsoft.Office.Server.UserProfiles.ProfileSubTypeManager]::Get($context)
  $defaultSubType = [Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::GetDefaultProfileName([Microsoft.Office.Server.UserProfiles.ProfileType]::User)
  $ps = $psm.GetProfileSubtype($defaultSubType)

  Write-Host "User Profile Objects setup complete"
  $Name = "testttttt"
  $pspm = $ps.Properties
  $Privacy1= "Public"
  $PrivacyPolicy1 ="Mandatory"
  $DisplayName1="Notifications Settings"
  $Description1 ="Custom2"
  #$xmlData.UserProfileSection.Section | ForEach-Object{
      $property = $pspm.GetSectionByName($Name)             
        if($property -eq $null)
        {
            $Privacy = $Privacy1
            $PrivacyPolicy=$PrivacyPolicy1
            $coreProp = $cpm.Create($true)
            $coreProp.Name = $Name
            $coreProp.DisplayName = $DisplayName1
            $coreProp.Description = $Description1


            $cpm.Add($coreProp)
            write-host -f green $_.Name section is created successfully             
        }
        else
        {
           write-host -f yellow $_.Name section already exists
        }
 #    }
 }

     #----------------Calling the function---------------------------------------------  
CreateUserProfileSection