PowerShell script for retrieving AD user attributes based on display name

Populating more than 1.000 people picker values based on users display name can be quite challenging when doing it manually. PowerShell to the rescue!

This script reads a TXT-file with 1 users’ display name per line. Per user it searches the local directory and outputs the displayName and sAMAccountName in a semicolon separated line (easy for Excel extraction).

PowerShell script:

function ConvertUser($user) { $search = New-Object DirectoryServices.DirectorySearcher([ADSI]“”) $search.filter = “(&(objectClass=user)(displayName=$user))” $results = $search.Findall() foreach($result in $results){ $userEntry = $result.GetDirectoryEntry() Write-Output('' + $userEntry.displayName + ';' + $userEntry.sAMAccountName) } } function ConvertUsers { process{ foreach($user In $_){ ConvertUser($user) } } } Get-Content “.\Users.txt” | ConvertUsers

TXT-file with users (filename: “Users.txt”):

Aaron Painter Adam Barr Alan Brewer Alan Steiner

Make a TXT-file with users display name (see example below). Then copy, paste and run the script above should do the trick.



Removing Super User and Super Reader account

A colleague of mine had issues with the object cache user accounts (Super User and Super Reader accounts). He used the blog post addressing the access denied errors. The post describes setting the Super User and Super Reader, but it did not describing removing both properties.

My colleague needed to remove the properties, this PowerShell script removes both properties:

# Remove properties $wa = Get-SPWebApplication -Identity "<WebApplication>" $wa.Properties.Remove("portalsuperuseraccount") $wa.Properties.Remove("portalsuperreaderaccount") $wa.Update() Write-Host("Properties count for " + $wa.Url + ": " + $wa.Properties.Count)

I hope it helps those who want to undo their settings. To complete the script:

# Get current properties $wa = Get-SPWebApplication -Identity "<WebApplication>" $user = $wa.Properties["portalsuperuseraccount"] $reader = $wa.Properties["portalsuperreaderaccount"] # Write current properties Write-Host("Properties count for " + $wa.Url + ": " + $wa.Properties.Count) Write-Host("Super user (" + $wa.Url + "): '" + $user + "'") Write-Host("Super reader (" + $wa.Url + "): '" + $reader + "'")

SharePoint Features and Solution Upgrading slide deck DevDays

Last Thursday I presented at DevDays 2011 in The Hague (NL). All sessions are recorded and can be viewed on Channel 9. It was a great time!

SharePoint features and solution upgrading

This was a level 300 session about SharePoint features and solutions upgrading.

The feature and solution framework used for the deployment of custom SharePoint solutions was introduced in SharePoint 2007. With SharePoint 2010 some major improvements have been made to the framework to allow for feature versioning and upgradability. This provides new ways to deal with application lifecycle management.

This presentation covers the feature and solution framework, explains when to use the feature upgrade and talks about upgrading existing activated and non-activated features. During the session different demos will be build supporting the different scenarios.

You can download the slide deck here:

Download PowerPoint

 Enjoy the video on my session on Channel 9!

Channel9 SharePoint Features en Solution Upgrading