PowerShell SharePoint PnP: Installing SharePoint PNP PowerShell

Open Windows Powershell as Administrator.

Run the following

Install-Module SharepointPNPPowershellOnline

Type A when prompted.

To verify the version installed type the following:

Get-Module SharePointPnPPowerShell* -ListAvailable | Select-Object Name,Version | Sort-Object Version -Descending

Type the following to connect to your SharePoint Online Environment replacing <YourTenant> with your Tenancy alias, e.g alanlearnsstuff12345

Read More

PowerShell SharePoint: Installing SharePoint Online Management Shell

Once upon a time there was a need to download an MSI and to install the SharePoint PowerShell Module that way, however, as all useful and trusted modules do one day it now can be found in the PowerShell Gallery at this linkMicrosoft.Online.SharePoint.PowerShell. If you were still to need it for some reason it can be located here. But don't bother doing that, have a read below and get started using SharePoint Online Management Shell.

So, to install the module, run PowerShell as administrator and type …

Install-Module -Name Microsoft.Online.SharePoint.PowerShell

Then to bring it in to use by sending this command …

Import-Module -Name Microsoft.Online.SharePoint.PowerShell

Now we have the module, installed and imported to the session let's connect …

Read More

PowerShell Office 365: SMTP Email Sent with PowerShell via Office 365

In this example, I have an extremely simple function called MyCode. The purpose of the function is only to demonstrate us taking any PowerShell output then passing it ot the body of an email and sending that email.

Here is a look at the output:

Once we have the output from MyCode it is all about how we pass that over to the email. That is achieved by using Send-MailMessage.

Read More

Powershell Office 365: Building a Hash Table and a Custom PSObject to Get-UserInfo

Here is a script that will quickly tell you some mailbox information and some mailbox statistics for an Exchange Online such as Office 365 mailbox. This will also work with Exchange Shell on Exchange 2013 on Premises.

The data is collated from 2 different cmdlets, Get-MsolUser and Get-MailboxStatistics. The data is then used to create an advanced function called Get-UserInfo.

This post serves as a demonstration in building a hash table and a custom PSObject, one of the most important aspects of PowerShell scripting. It also serves to demonstrate the principal of gathering output from various cmdlets and bringing them together as one.

It has been assumed that you have installed the PowerShell Module called MSOnline and authenticated to Office 365 via PowerShell in the usual way.

If you were to "Dot Source" the script using PowerShell.exe then you would run it with the following :

Get-UserInfo -UPN user@mail.com -Verbose -ErrorLog

This script example will only support one UserPrincipalName input although can be easily changed to accept multiple, CSV input and accross the pipeline if required. This is outwith the scope of this post.

Read More