$adminurl='https://xxxx-admin.sharepoint.com'
$fname = 'PropertyInternalNameGoesHere'
$creds = Get-AutomationPSCredential -Name 'AutomationCredName'
$spcreds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($creds.UserName, $creds.Password)
$web = new-webserviceproxy -uri "$adminurl/_vti_bin/UserProfileService.asmx?wsdl" -usedefaultcredential $false
$web.Credentials = $spcreds
$uri = new-object system.uri($adminurl)
$container = new-object system.net.cookiecontainer
$container.setcookies($uri,$spcreds.GetAuthenticationCookie($adminurl))
$web.cookiecontainer = $container
#users previously retrieved from Azure AD
foreach($user in $users){
$acctname = "i:0#.f|membership|" + $user.userprincipalname
write-output "`r`n retrieving $acctname property $fname"
$udata = $web.Getuserprofilebyname($acctname)
$ufield = $web.getuserpropertybyaccountname($acctname,$fname).Values | select -expandproperty value
write-output $ufield
}
Views:
Keywords: azure; sharepoint online; automation; web services; user profile