Point Deep

Mundeep's Tech Blog

Calling powershell functions with multiple parameters

Posted by mundeep on March 1, 2012

When calling a powershell function with multiple parameters, ensure the parameters are passed in space separated and not comma-separated as the later causes all the values to be passed in as an array to the first parameter!

See Stackoverflow: Powershell Multiple Function Parameters for an example.


2 Responses to “Calling powershell functions with multiple parameters”

  1. Carlos said

    Hey – so once you have created all these subtypes, is there a way to assign each user profile the desired subtype (with PowerShell)? I’ve tried the following but it is not successful ;-(

    $site = Get-SPSite $CA_Url
    $context = Get-SPServiceContext($site)
    $profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
    $profileSubtypeManager = [Microsoft.Office.Server.UserProfiles.ProfileSubTypeManager]::Get($context)

    $profileSubtype = $profileSubtypeManager.GetProfileSubtype(“SampleSubtype”)
    $userProfile = $profileManager.GetUserProfile(“contoso\testuser1”)
    $userProfile.ProfileSubtype = $profileSubType

  2. Carlos said

    Apparently the issue is that the $userProfile.Commit() does not think a change has occurred and therefore does not update the subtype. To circumvent this you need to change another property to trigger the commit to work. For instance you could add $SavedTitle = $userProfile[“Title”].Value, then change that value with $userProfile[“Title”].Value = “X” before the commit. Then change it back using your $SavedTitle and Commit again so only the SubType was updated.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: