I'm trying to build a fully functioning powershell script that will merge user accounts, loop through all the site collections and delete the 2 user accounts, then execute audience compilation. I've got parts 1 and 2 working after a bit of work, but I'm hung up on hooking into audiences. I've seen this post by Per, and it always bombs out on line 3 with:
New-Object : Exception calling ".ctor" with "1" argument(s): "Object reference not set to an instance of an object." At line:3 char:18 + $upm = New-Object <<<< Microsoft.Office.Server.UserProfiles.UserProfileManager($context); + CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
If I do a $context
, it gives me a GUID of all zeroes. I'm developing this on my local windows 7 machine, full admin access to everything.
$site = Get-SPSite "http://localhost"
$context = Get-SPServiceContext $site;
$upm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context);
$audmgr = New-Object Microsoft.Office.Server.Audience.AudienceManager($context)
$aud = $audmgr.GetAudience("Irvine")