Quantcast
Channel: SharePoint 2013 - Setup, Upgrade, Administration and Operations forum
Viewing all articles
Browse latest Browse all 21070

How can I access User Profile Services in SharePoint 2013 using powershell

$
0
0

I tried this code to access user profile information:

add-pssnapin "Microsoft.Sharepoint.Powershell";
$serviceContext = Get-SPServiceContext("my central admin");
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext);
foreach($usrProfile in $profileManager.GetEnumerator()) {
Write-Host $usrProfile.AccountName "|" $usrProfile.DisplayName;
}

But I am getting these errors:

 

New-Object : Exception calling ".ctor" with "1" argument(s): "UserProfileApplicationNotAvailableException_Logging :: 
UserProfileApplicationProxy.ApplicationProperties ProfilePropertyCache does not have 5a2fe999-9785-442e-882e-77f850c64f54"
At line:3 char:19
+ $profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileMan ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvocationException
    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand

You cannot call a method on a null-valued expression.
At line:4 char:24
+ foreach($usrProfile in $profileManager.GetEnumerator()) {
+                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Can someone help please

Thanks


Viewing all articles
Browse latest Browse all 21070

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>