Some Users not in siteUserInfoList - sharepoint

I have a script to list all the users that have accounts on sharepoint. However, not all them are being listed. There are only 5/8 Marks that are listed for example.
I'm using powershell and a query:
"<Query><OrderBy><FieldRef Name='ID' /></OrderBy></Query>"
I don't know why there are not all showing. I can find them under the portal and admin center.

Users are added to the User Information List when they login to the site or granted specific permissions (not through an AD Group).
You can read more on SharePoint.StackExchange.com at How is the user information list populated?

You can write a PowerShell script(named ListWebUserInformationListItems.ps1) as following:
# Run with SharePoint 2010 Management Shell
$webUrl = Read-Host "Enter the web url"
$web = Get-SPWeb $webUrl
$list = $web.Lists["User Information List"]
$query = New-Object Microsoft.SharePoint.SPQuery
$queryCamlString = '<Query><OrderBy><FieldRef Name="Title" Ascending="True" /></OrderBy></Query>'
$query.Query = $queryCamlString
$userInformationListItems = $list.GetItems($query)
foreach($userInformationListItem in $userInformationListItems)
{
echo $userInformationListItem.Title
}
Then execute the script and input the web url when console window display the "Enter the web url" message.
Note: You can use SPQuery the get the User Information List items which are the users in this web application. The users are not all the users in the farm. And if you add a ADGroup to the SharePoint, you will add the only one SharePoint user to user information list(The SharePoint User stand for the ADGroup, the ADUser in the ADGroup will not present to the user information list).
The User Information List item title will display in the console window.
More over:
You can visit the "http://[your web application url]/_catalogs/users/detail.aspx" to view the users who are in the web application.
Hope the answer will help you

I think you might get better of by listing all User Profiles instead. By doing this, you will at least get a list of all users that have been synchronized into SharePoint. Something like:
$site = Get-SPSite "your URL"
$context = Get-SPServiceContext $site
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$profiles = $profileManager.GetEnumerator()
foreach($profile in $profiles)
{
$displayName = $profile.DisplayName
}

Related

Sharepoint Online - Site Data Collection change

I am currently trying to disable a OneDrive for my organisation. It works pretty well for new users, but old ones got access. I worked out one solution - when I take away collection admin rights user cannot use OneDrive anymore.
But I have 1000 users, and I will die changing permissions by hand, therefore is there any script to set all site collection admins to one person?
I mean those settings:
https://i.stack.imgur.com/A63RZ.png
If you want to disable OneDrive and don't want anyone to access it, instead of changing permissions, you can lock all OneDrive sites via PowerShell code:
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
#Parameters
$AdminCenterURL = "https://xxx-admin.sharepoint.com"
Try {
#Connect to SharePoint Online Admin Center
Connect-SPOService -Url $AdminCenterURL -Credential (Get-Credential)
#Get All OneDrive for Business Sites in the Tenant
$OneDriveSites = Get-SPOSite -Limit ALL -includepersonalsite $True -Filter "Url -like '-my.sharepoint.com/personal/'"
#Loop through each OneDrive Site
Foreach($Site in $OneDriveSites)
{
Set-SPOSite -Identity $Site -LockState "NoAccess"
Write-host "Scanning site:"$Site.Url "is locked"-f Yellow
}
}
Catch {
write-host -f Red "Error locking Sites:" $_.Exception.Message
}
Result is:
After that, when users try to access OneDrive, a 403 error will be returned.
About Set-SPOSite

SharPoint People Picker

Hello Is there any People Picker Service/Web Service in SharePoint 2013? Actually i want to check some user existence in People Picker through PowerShell. I have a list of users in csv file.
Please refer the following powershell to check a user exists in a group:
$w = get-spweb http://my
$gs = $w.SiteGroups
$g = $gs[12]
$user = $g.Users.GetByEmail("user#domain.com")
if($user -eq $null){write-host "User Not Found"}

Sharepoint 2013 MobileExcelWebAccess Feature missing when creating subsite using a site template

I had a subsite in a site collection I wanted to transfer to another site collection (both in Sharepoint 2013). I made a site template with content out of it so I can transfer it to another site collection. I uploaded the solution and activated it. I made sure the activated features were completely identical. However, when I create a new subsite and choose to use the uploaded solution, I continue to receive a error message saying it is missing a feature called "MobileExcelWebAccess."
I have no clue where to find that feature. I literally enabled every site feature and site collection feature but I still end up with that error. I've read on other resources that it could be found on Central Admin but I don't have access there.
If I can't enable it in the new site, is there a way to disable it in my old site?
Try running this from a SharePoint 2013 Management Shell: Enable-SPFeature MobileExcelWebAccess -Url http://[replace with your url]
The simple line script from Ola Ekdahl did not work for me, but this did:
Replace the $url with your site collection url
save the script in .ps1 file
Open SharePoint Online Management Shell in Administrator mode and execute the script like .\
A prompt will be poped-up that asks your credential (Administrator) for the site collection
$url = "https://<your site collection url>"
$clientDll = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
$runtimeDll = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
$cred = get-credential
$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($url)
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($cred.username, $cred.password)
$clientContext.Credentials = $credentials
if (!$clientContext.ServerObjectIsNull.Value)
{
Write-Host "Connected to SharePoint site: '$Url'" -ForegroundColor Green
}
$clientContext.Site.Features.Add('e995e28b-9ba8-4668-9933-cf5c146d7a9f',$true,[Microsoft.SharePoint.Client.FeatureDefinitionScope]::None)
$clientContext.ExecuteQuery()
source: http://mahedevelopment.blogspot.gr/2016/07/sharepoint-online-mobileexcelwebaccess.html

Configuring a sharepoint site subscriptions user account directory path with the object model

I'm working on multi tenant provisioning in sharepoint and I'm having trouble figuring out if you can set the user account directory path for a site subscription using the sharepoint object model. I know this can be done through powershell with the following cmdlet.
$sub = New-SPSiteSubscription
$sub | Set-SPSiteSubscriptionConfig -UserAccountDirectoryPath "OU=AlpineBikeStore,OU=Hosting,DC=contoso,DC=com" -FeaturePack "50976ac2-83bb-4110-946d-95b4b6e90d42" -Confirm:$false
So far I've got the following code that will create a site subscription with a default site and feature pack. However, I can't figure out how to set the path to the users OU in active directory.
//Create a default admin site for this tenant
var site = new SPSite("https://contoso.com/", userToken);
//Create the subscription and assign the default admin site to it.
var sub = SPSiteSubscription.Create();
sub.Add(site);
//Get the feature pack and assign it to the subscription
var featurePacks = SPSiteSubscriptionSettingsManager.Local.GetAllFeaturePacks();
var pack = featurePacks.SingleOrDefault(x => x.Id == Guid.Parse("50976ac2-83bb-4110-946d-95b4b6e90d42"));
SPSiteSubscriptionSettingsManager.Local.AssignFeaturePackToSiteSubscription(pack, sub);
Any suggestions?
As Rikard suggested I used reflection for you.
Set-SPSiteSubscriptionConfig does the following:
if (this.m_UserAccountDirectoryPathSpecified)
{
SPSiteSubscriptionPropertyCollection adminProperties = this.m_SettingsManager.GetAdminProperties(this.m_ResolvedIdentity);
if (!string.IsNullOrEmpty(this.UserAccountDirectoryPath))
{
adminProperties.SetValue("UserAccountDirectoryPath", this.UserAccountDirectoryPath);
}
else
{
adminProperties.Remove("UserAccountDirectoryPath");
}
adminProperties.Update();
}
As you can see it uses the GetAdminProperties method to get the admin properties of the SPSiteSubscriptionManager.
It then goes ahead and just updates the SPSiteSubscriptionProperty inside the adminProperties collection with the value "UserAccountDirectoryPath".
All you need to do now is to set this as well and you're done. You can use a program such as ILSpy to look at the code of the SharePoint Powershell commandlets. In this case you could have found the code in Microsoft.SharePoint.PowerShell.SPCmdletSetSiteSubscriptionConfig.

Access denied attempting to Manage Search service application

When I click Manage on the Search Service application I get the access denied page.
ULS gives me nothing but:
"Unknown SPRequest error occurred. More information: 0x80070005"
We have upgraded through Search Foundation to Search Server Express to Search Server.
Our main web app is claims based authentication whereas our Central Administration is NTLM.
I found the following post which seems to be the same issue but there doesn't appear to be a solution.
http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010setup/thread/2deafa72-6e91-4c43-aed3-895b24d504ac
Any advice on hunting down permissions issues of this type would be greatly appreciated.
I had the same problem but since I had no access to the "farm account" mentioned above, I had to remove this webpart programmatically.
Powershell:
$site = new-Object Microsoft.SharePoint.SPSite("http://path-to-central-admin:<portnumber>/")
$web = $site.OpenWeb()
$page = $web.Url + "/searchadministration.aspx"
$webpartmanager = $web.GetLimitedWebPartManager($page, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
for($i=0;$i -lt $webpartmanager.WebParts.Count;$i++)
{
if ($webpartmanager.WebParts[$i].title -eq "Shortcuts")
{
$webpartmanager.DeleteWebPart($webpartmanager.Webparts[$webpartmanager.WebParts[$i].ID])
}
}
$web.Update();
$site.Dispose();
Save the script as a .ps1-file and call from the SharePoint 2010 Management Shell! :)
Found the solution to my problem.
The links web-part at the top of the Search Administration page was being auto-populated with links, some of them I didn't have access to.
I logged in with the farm account and closed this worse-than-useless web-part and all was well.

Resources