modery.net

All posts tagged powershell

Over at the SharePoint Community, Balamurugan Kailasam posted that he was able to download the DLLs from SharePoint Online. While it is unclear at the moment why this is possible (maybe required by some tools?), or if this might be deactivated at some point, I decided nevertheless to write a small PowerShell script to download all DLLs that I’m aware of.

The code below create a subfolder with the current time as the name (in case you want to run it regularly and keep the older versions), and then downloads all the files into it. Additionally, it creates a file called info.txt with the version information of all DLLs

[Environment]::CurrentDirectory=(Get-Location -PSProvider FileSystem).ProviderPath
#replace contoso with your own tenant
$spUrl = "https://contoso.sharepoint.com/"

$dllsVTI = @("Microsoft.BusinessData.dll", "Microsoft.Office.Client.Policy.dll", "Microsoft.Office.Client.TranslationServices.dll", 
		"Microsoft.Office.DocumentManagement.dll", "Microsoft.Office.Excel.Server.Udf.dll", "Microsoft.Office.Excel.Server.WebServices.dll", 
		"Microsoft.Office.Policy.dll", "Microsoft.Office.SecureStoreService.Server.Security.dll", "Microsoft.Office.Server.dll", 
		"Microsoft.Office.Server.Search.Applications.dll", "Microsoft.Office.Server.Search.Connector.dll", "Microsoft.Office.Server.Search.dll", 
		"Microsoft.Office.Server.Search.ExchangeAdapter.dll", "Microsoft.Office.Server.UserProfiles.dll", 
		"microsoft.office.sharepoint.clientextensions.dll", "Microsoft.Office.Word.Server.dll", "Microsoft.Office.Workflow.Actions.dll", 
		"microsoft.office.workflow.tasks.dll", "Microsoft.SharePoint.Client.dll", "Microsoft.SharePoint.Client.DocumentManagement.dll", 
		"Microsoft.SharePoint.Client.Publishing.dll", "Microsoft.SharePoint.Client.Runtime.dll", "Microsoft.SharePoint.Client.Search.Applications.dll", 
		"Microsoft.SharePoint.Client.Search.dll", "Microsoft.SharePoint.Client.ServerRuntime.dll", "Microsoft.SharePoint.Client.Taxonomy.dll", 
		"Microsoft.SharePoint.Client.UserProfiles.dll", "Microsoft.SharePoint.Client.WorkflowServices.dll", "Microsoft.SharePoint.dll", 
		"Microsoft.SharePoint.Linq.dll", "Microsoft.SharePoint.Portal.dll", "Microsoft.SharePoint.Publishing.dll", "Microsoft.SharePoint.Search.dll", 
		"Microsoft.SharePoint.Search.Extended.Administration.Common.dll", "Microsoft.SharePoint.Search.Extended.Administration.dll", 
		"Microsoft.SharePoint.Search.Extended.Administration.ResourceStorage.dll", "Microsoft.SharePoint.Security.dll", "Microsoft.SharePoint.Taxonomy.dll", 
		"Microsoft.SharePoint.Taxonomy.Intl.dll", "microsoft.sharepoint.WorkflowActions.dll", "Microsoft.SharePoint.WorkManagement.Client.dll", 
		"Microsoft.Web.CommandUI.dll", "SHTML.dll", "spnativerequestmodule.dll")
		
$dllsAPP= @("Microsoft.Office.Discovery.Soap.dll", "Microsoft.Office.DocumentManagement.Pages.dll", 
 "Microsoft.Office.officialfileSoap.dll", "Microsoft.Office.Policy.Pages.dll", 
 "Microsoft.Office.Server.Search.Applications.ServerProxy.dll", "Microsoft.Office.Server.Search.ServerProxy.dll", 
 "Microsoft.Office.Server.UserProfiles.ServerStub.dll", "Microsoft.Office.Server.WorkManagement.ServerProxy.dll", "Microsoft.Office.SlideLibrarySoap.dll", 
 "Microsoft.Office.TranslationServices.ServerStub.dll", "Microsoft.Office.Workflow.Pages.dll", "Microsoft.Office.WorkflowSoap.dll", 
 "Microsoft.SharePoint.ApplicationPages.dll", "Microsoft.SharePoint.AppMonitoring.ApplicationPages.dll", "Microsoft.SharePoint.OfficeExtension.ApplicationPages.dll", 
 "Microsoft.SharePoint.Portal.Proxy.dll", "Microsoft.SharePoint.Taxonomy.ServerStub.dll", "Microsoft.SharePoint.WorkflowServices.ApplicationPages.dll", 
 "Microsoft.SharePoint.WorkflowServices.ServerProxy.dll", "STSSOAP.DLL")

$folder = new-item -type directory $(get-date -f yyyy-MM-dd_HH_mm_ss) 

function GetDll([string]$dll, [string]$path) {
	$file = $folder.FullName+"\"+$dll
	$wc = (New-Object System.Net.WebClient)
	write-host "Downloading ",$spUrl,$path,$dll
    	$wc.DownloadFile($spUrl + $path + $dll, $file)
	$item = get-item $file
	if($item) {
		add-content "$($folder)\info.txt" "$($item.Name) - $($Item.VersionInfo.ProductVersion)"
	}
}

foreach($dll in $dllsVTI) {
	GetDll $dll "_vti_bin/"
}

foreach($dll in $dllsAPP) {
	GetDll $dll "_app_bin/"
}

 


A few days ago, Microsoft released a new version of their SharePoint Online Management Shell (the PowerShell cmdlets that can be used to manage SharePoint Online). In this blog post, I will briefly explain what was changed and what you can do now with the new options. Note: The new internal version number for the cmdlets is : 15.0.4569.1506

Sites

The first new attribute that is available is for Site Collections and is called SharingCapability. Basically, this attribute tells you if sharing has been enabled for a site collection or not. The three possible values are Disabled, ExternalUserSharingOnly, and ExternalUserAndGuestSharing (see also http://msdn.microsoft.com/en-us/library/microsoft.online.sharepoint.tenantmanagement.sharingcapabilities(v=office.15).aspx)

When you run Get-SPOSite  | select Url, SharingCapability you’ll get a list of all site collections and the corresponding Sharing Capability.
spocmdlets1

You can also set the values, so if you want to enable sharing for a site collection for authenticated users only, run Set-SPOSite -Identity <YourSiteUrl> -SharingCapability ExternalUserSharingOnly:
spocmdlets2

Tenant

For tenants, there are three new attributes: DisplayStartASiteOptionSharingCapabilityStartASiteFormUrl

You can get the current settings by simply running Get-SPOTenant:
 spocmdlets3

SharingCapability simply shows you which settings have been set for your tenant in general.

DisplayStartASiteOption and StartASiteFormUrl can help you with allowing users to create new site collections, and which form to use. For example, there’s a sample app from Richard diZerega from Microsoft that you could customise for this purpose.

DisplayStartASiteOption controls if the “new site” link is available when you click on Websites in the Ribbon. If it’s deactivated, you don’t get to see such an option:
spocmdlets6

Turning it on (Set-SPOTenant -DisplayStartASiteOption $true) will provide you with the link:
spocmdlets9

If you don’t want to use the default form, you can then also specifiy your custom form via Set-SPOTenant -StartASiteFormUrl  <FormUrl>.

Please note that these two options are also available through the UI.  These two options can be found in the SharePoint Admin Center under Settings:
spocmdlets11

If DisplayStartASiteOption  is set to false, “Hide the link” is activated for Start a Site:

spocmdlets7

Setting it to true, “Show the link” becomes active:

spocmdlets8

Lastly, if you set a URL for StartASiteFormUrl, the corresponding field is set:

spocmdlets10

 External Users

The last changes in the new version of the cmdlets offer a few new attributes for external users: InvitedByWhenCreatedAcceptedAs

When you run Get-SPOExternalUser, you can see who invited the external user, when he accepted, and with which email address:
spocmdlets4

Additionally, you also have the option to get the external users of a single site collection only, and not the whole tenant, by running Get-SPOExternalUser with the -SiteURL parameter:
spocmdlets5

 


All sessions of the SharePoint Conference 2014 have been posted already on Channel 9! If you plan to watch a lot or even all of them, here’s a little PowerShell script that will help to download them. The original is from 2012 and was created by Vlad Catrinescu, with some very minor modifications (basically added one [xml] and changed the RSS feed) it’s also working this. year.

[Environment]::CurrentDirectory=(Get-Location -PSProvider FileSystem).ProviderPath
$rss = (new-object net.webclient)

$a = [xml]($rss.downloadstring("http://channel9.msdn.com/Events/SharePoint-Conference/2014/RSS/mp4high"))

$a.rss.channel.item | foreach{
 $code = $_.comments.split("/") | select -last 1

 $url = New-Object System.Uri($_.enclosure.url)

 $file = $code + "-" + $_.creator + "-" + $_.title.Replace(":", "-").Replace("?", "").Replace("/", "-").Replace("<", "") + ".mp4"

 if (!(test-path $file))
 {
    $file
    $wc = (New-Object System.Net.WebClient)
    $wc.DownloadFile($url, $file)
 }
}

During the past few months, I presented a few times online, at conferences, and at user groups. All those presentations were uploaded to my SlideShare account recently.

I uploaded multiple presentations on the topic of SharePoint Online management with PowerShell due to the fact that, depending on audience, I sometimes included infos on Exchange Online / Lync Online as well. Also, I constantly update that presentation with new information, such as newly available cmdlets.


As an Office 365 MVP, I’m an active member of the SharePoint and Office 365 community. I blog, I write articles and books, I hold webinars, and sometimes I also present at conferences. I’m happy to announce that I’ll be speaking twice in the Netherlands, once in November at SharePoint Connections 2013, and in January at the first European Office 365 connect.

SharePoint Connections Amsterdam 2013 – 19.-21.November 2013


I’ll be presenting alongside a whole lot of other great people, among them some MVPs and even MCSMs. If you intend to come as well, you can get a 10% discount with thede SP288 when you register!

My presentations are:
Hybrid SharePoint 2013 and Office 365 Environments for Decision Makers
What value does hybrid SharePoint 2013 and Office 365 environments offer, which drawbacks do they have? Why do companies use them? How do you plan them, and which governance aspects need to be considered? And which resource requirements do they impose? These and many more questions will be answered in this session, targeted at IT Managers and other decision makers who want to learn more about hybrid environments. Come see!

Automating Office 365 with PowerShell
With the new Office 365, there are many more possibilities for administrators to manage Office 365 with PowerShell, especially regarding SharePoint Online. In this session, you will get an overview of the existing cmdlets and learn how common tasks such as creating a mailbox and granting access to a SharePoint site can be automated.

 

European Office 365 connect – 28.-30.January 2014


I’ll be back in the Netherlands in January, when I’ll present at the very first European Office 365 connect. The code for a 10% discount during registration is GB274.
My 2 presentations are:

Real-Life Use Cases for SharePoint Online
You’ve got SharePoint Online, but you think you’re not really leveraging it yet to get maximum value out of it? Or you’re looking generally for ideas on how it could be used? In this session, you will get to see how other companies use SharePoint Online, how they integrate it effectively into their IT architecture, and what kind of solutions they build on it.

Migrating to SharePoint Online
Companies that start using Office 365 usually have a lot of information and solutions already in their organisation. How can they move their data to SharePoint Online? Can all solutions be easily moved as well, or are there restrictions to consider? Who needs to be involved in a migration, which resources are required, and which steps need to be undertaken at which time? Get answers to these questions in this session!

 

This announcement is also available in German / Diese Ankündigung ist auch auf Deutsch verfügbar


For the third time, the SharePoint Connections will take place in Amsterdam on 19th and 20th November 2013. There’s a very nice line-up of lots of international and renowned speakers (Michael Noel, Joel Olesen, Penelope Coventry, Steve Fox, Dan Holme, Mirjam van Olst, Spencer Harbar to mention a few), and I’m happy to be presenting alongside them as well.

600-rene-m

My two sessions there are:

Hybrid SharePoint 2013 and Office 365 environments for decision makers
Which value do hybrid SharePoint 2013 and Office 365 environments offer, which drawbacks do they have? Why do companies use them? How do you plan them, and which governance aspects need to be considered? And which resource requirements do they impose? These and many more questions will be answered in this session, targeted at IT Managers and other decision makers who want to learn more about hybrid environments

Automating Office 365 with PowerShell
With the new Office 365, there are many more possibilities for administrators to manage Office 365 with PowerShell, especially regarding SharePoint Online. In this session, you will get an overview of the existing cmdlets, and learn how common tasks such as creating a mailbox and granting access to a SharePoint site can be automated.

 

Hope to see you there!

 


licensed-users-feature-small

Let’s say you want to have a list of all licensed users in your Office 365 environment. You could look at the Office 365 Dashboard under Users and look at the list there, but quite often you may want to have that information in a spreadsheet for further processing. How to?, you ask? PowerShell to the rescue!

[info_box]More information on available PowerShell cmdlets for Office 365 can be found on the following site: http://onlinehelp.microsoft.com/office365-enterprises/hh125002 [/info_box]

Open PowerShell, connect to Office 365 (Connect-MsolService), and test the following cmdlets:

Get-MsolUser

“The Get-MsolUser cmdlet can be used to retrieve an individual user, or list of users. An individual user will be retrieved if the ObjectId or UserPrincipalName parameter is used.”

So, we’ve got a list of all users right now. Let’s try to export it to a CSV file that we can then open with Excel

Get-MsolUser | Export-Csv c:\allUsers.csv

If we open the file allUsers.csv now, we get to see all users in our Office 365 environment, together with lots of additional attributes

We’re just interested in the ones with licenses, so let’s filter a bit:

Get-MsolUser | Where-Object {$_.isLicensed -eq "TRUE"}

Great! We’ve now reduced the list to only those users for which the attribute isLicensed is set to True. Meeting Rooms don’t need a license, thus they don’t show up here.

Next step: exporting this list (in my case only 1 user) to Excel:

Get-MsolUser | Where-Object {$_.isLicensed -eq "TRUE"} | Export-Csv c:\licensedUsers.csv

A combination of the two code snippets above, this one here grabs all users, filters them, and exports the result to a CSV file. Opening that file, we can see the list of all users, however also with all attributes

As a last steps, let’s reduce the results further by only displaying the UserPrincipalName attribute/column/property in our CSV file:

Get-MsolUser | Where-Object {$_.isLicensed -eq "TRUE"} | 
Select-Object -property "UserPrincipalName" | Export-Csv c:\licensedUsers.csv

(After filtering, we then proceed to select only the UserPrincipalName property of all our users before exporting them.

References:

Using the Where-Object Cmdlet
Using the Select-Object Cmdlet
Using the Export-Csv Cmdlet 
Windows PowerShell cmdlets for Office 365