Wednesday, 31 August 2016

Office 365 License Report using PowerShell

We can use the Azure AD powershell cmdlet Get-MsolUser to get all office 365 users. This command also returns the license based property IsLicensed and Licenses (applied license details).

Note: Before proceed, Install and Configure Azure AD PowerShell

Run the below command to get all the office 365 users.
Get-MsolUser -All  | Select-Object UserPrincipalName, DisplayName, isLicensed
The below command returns only licensed office 365 users.
Get-MsolUser -All | Where-Object { $_.isLicensed -eq $true } |
Select-Object UserPrincipalName, DisplayName, Department
You can also extract what are the licenses has been assigned to every users.
Get-MSOLUser -All | Where-Object { $_.isLicensed -eq $true } |
Select-Object UserPrincipalName, DisplayName, {$_.Licenses.AccountSkuId}
Run the below command to export all the licensed users and applied license details to csv file.
Get-MSOLUser -All | Where-Object { $_.isLicensed -eq $true } |
Select-Object UserPrincipalName, DisplayName, {$_.Licenses.AccountSkuId} |
 Export-CSV "C:\\office-365-users-license.csv" -NoTypeInformation -Encoding UTF8
You can read this technet article: https://technet.microsoft.com/en-us/library/dn771771.aspx to get fine-tuned license report, like all licensed users who are enabled for specific license plan.

Tuesday, 30 August 2016

Powershell - Write Output in Console

There are multiple ways to write output to powershell console, you can simply put quotation marks in any string to display on the screen and you can also use the powershell cmdlets Write-Host and Write-Output.
"Hello World1"
Write-Host "Hello world2"
Write-Output "Hello World3"
The Write-Host is the best choice in many cases, it is the cmdlet designed specifically to display output only on powershell console screen. You can display the output with background color and foreground color by using Write-Host.
Write-Host "Hello world" -BackgroundColor "Green" -ForegroundColor "Black"
Write-Output cmdlet should be used when you want to send data into the pipe line, but not necessarily want to display it on screen. Because, you can't pipe the output when you use Write-Host.
function Test-Output {
    Write-Output "Hello World"
}

function Receive-Output {
    process { Write-Host $_ -ForegroundColor Yellow }
}

#Output piped to another function, not displayed in first.
Test-Output | Receive-Output
You can get more detail about the cmdlets Write-Host and Write-Output from this article : https://blogs.technet.microsoft.com/heyscriptingguy/2011/05/17/writing-output-with-powershell/

Host Web vs App Web in SharePoint

If you are newbie for SharePoint apps development, you might be wondering to know clear idea about the terminologies host web and app web (add-in web).

The special site where the app is deployed is called an app web. The site where the app is installed is called the host web. In other words, the SharePoint add-in which host SharePoint components (e.g. lists, content types etc.) is called the app web.

Consider that you are developing an app with custom ribbon action in List view page and the custom action click redirects you to the special site page. Here, the custom action placed in host web and special page is an app web

App Web - The special website to which the add-in is deployed

Host Web - The site on which the App is installed

For more detail checkout this article : https://msdn.microsoft.com/en-us/library/office/fp179925.aspx

Monday, 29 August 2016

How to change product key in Office or Outlook 2016

Today, I have installed Office 2016 setup to use Outlook 2016 and put in the product key when I open the outlook. After entering the product key, it sends to the product Activation page, the product activation message says that it is valid key but it is already used. So, now I have been forced to change the new product key.

Find and Reset Office 2016 License Key using VBScript

1. Open a command prompt (Start-> Run: cmd).
2. Run the following commands:
cscript "C:\Program Files\Microsoft Office\Office16\ospp.vbs" /dstatus
3. Note it the 5 digit partial product key (You may find multiple keys).
How to change license key in Office or Outlook 2016
4. Then run the following command after replacing the <partial_key> with the 5 digit key that you got previous step.
cscript "C:\Program Files\Microsoft Office\Office16\ospp.vbs" /unpkey:<partial_key>
This will uninstall an installed product key with partial product key you noted earlier. Uninstall all of the keys.

5. Now you should be able to set the license key as usual way. Or you can use following command after replacing the <new_full_key> with your new license key:
cscript "C:\Program Files\Microsoft Office\Office16\ospp.vbs" /inpkey:<new_full_key>
Then you need run the below command to activate license.
cscript "C:\Program Files\Microsoft Office\Office16\ospp.vbs" /act

Note:

Depending on the combination of Office version you might have to change the path to Program Files(x86)

For (x64 Office 2016) : C:\Program Files\Microsoft Office\Office16\
For (x86 Office 2016): C:\Program Files(x86)\Microsoft Office\Office16\

For (x64 Office 2013) : C:\Program Files\Microsoft Office\Office13\
For (x86 Office 2013): C:\Program Files(x86)\Microsoft Office\Office13\

Friday, 26 August 2016

Powershell - Check Contains String In Where Object

You can use the Where-Object cmdlet to filter objects from a collection based on their property values. We can use the comparison operator like with wildcard character to check if a property of object contains a specific string.
Note: You can not use the comparison operator contains to check the contains string, because it's designed to tell you if a
collection of objects includes ('contains') a particular object
The following command returns all the processes in current machine.
Get-Process | Select ID,ProcessName
If you want to list only the process which contains string '32' in processname, you need to use the below command.
Get-Process | Where-Object { $_.Name -like '*32*' }
By default like operator ignore the case-sensitive check. To perform a case-sensitive comparison just prefix the word "c" with like operator ("clike").
Get-Process | Where-Object { $_.Name -clike '*rundll*' }
If you want to check starts with string, you can use the same like operator with appending * at the end of the string alone.
Get-Process | Where-Object { $_.Name -like 'rundll*' }
Likewise, to check ends with string, need to append * at start of the string.
Get-Process | Where-Object { $_.Name -like '*host' }

Thursday, 25 August 2016

Yammer is going to work with Office 365 Groups

As Microsoft moving the most valuable Office 365 IT Pro discussion network from Yammer to new lithium based Office 365 Network, most of the people's feeling is what Microsoft going to do with Yammer. Whether they are going kill Yammer to promote Office 365 Groups? or they have any other idea?.

Yammer is not dead, it’s growing as a part of Office 365 Groups service. That’s a good thing for your users and team scenarios. You can choose for your Group whether you want conversations to happen in Outlook (Email) or in Yammer (Social Network). You’ll also have other Office 365 Groups features available in Yammer, including SharePoint Team Site for Files, a Shared Calendar (powered by Exchange), a OneNote shared notebook, Planner boards, Power BI and Connectors so you’ll finally have all the integration points that you have waited so for.

Checkout this great article : https://naomimoneypenny.com/2016/08/24/yammers-place-in-office-365-groups/ for more information regarding Office 365 Groups and Yemmer's current uncertainty mode.

As prior step, all of these changes and value adds, rely on having the switch that says ‘Enforce O365 Identity‘ pushed in Yammer. As Yammer becomes a core service for your organization, you’ll want users to be able to log into it seamlessly, just like any other Office 365 service. Additionally, you’ll probably want to maintain a single identity for all Office 365 users for easier user management. You can achieve both of these goals by enforcing Office 365 identity in Yammer. By enforcing Office 365 identity in Yammer and configuring federated identity for Office 365, admins can achieve single sign-on (SSO) capabilities for all services in Office 365, including Yammer.

Checkout this detailed article : Enforce Office 365 identity for Yammer users  for more information

Wednesday, 24 August 2016

Powershell - Check If String Contains Word

We can use the powershell's like operator with wildcard character to check if a string contains a word or another string with case-sensitive and case-insensitive.
Note: You can not use the comparison operator contains to check the contains string, because it's designed to tell you if a
collection of objects includes ('contains') a particular object
The following method is used to check if a string contains a word using like operator. By default like operator ignore the case-sensitive check.
$strVal ='Hello world'
if($strVal -like '*World*') {
      Write-Host 'Your string contains the word world'
} else {
      Write-Host 'Your string does not contains the word world'
}
To perform a Case-Sensitive comparison just prefix the word "c" with like operator ("clike").
$strVal ='Hello world'
if($strVal -clike '*world*') {
      Write-Host 'True'
} else {
      Write-Host 'False'
}
We can also use the built in .NET string extension function Contains to check whether a string contains a another string.
$strVal ='Hello world'
if($strVal.Contains('world')) {
     Write-Host 'True'
} else {
     Write-Host 'False'
}
The .Contains() function is case sensitive. If you want to use the Contains() method for case-insensitive check, convert both strings to one case before compare.
$strVal ='Hello world'
if($strVal.ToLower().Contains('world'.ToLower())) {
     Write-Host 'True'
} else {
     Write-Host 'False'
}

Tuesday, 23 August 2016

Powershell - Check If String Starts With IgnoreCase

Checking a string is startswith some character(or a string) is common need for every kind of powershell script. We can use the powershell's like operator with wildcard character to check the startswith string for both case-sensitive and case-insensitive.

The following method is used to check if a string is starts with another string using like operator. By default like operator ignore the case-sensitive check.
$strVal ='Hello world'
if($strVal -like 'hello*') {
      Write-Host 'Your string is start with hello'
} else {
      Write-Host 'Your string does not start with hello"'
}
To perform a Case-Sensitive comparison just prefix the word "c" with like operator ("clike").
$strVal ='Hello world'
if($strVal -clike 'Hello*') {
      Write-Host 'True'
} else {
      Write-Host 'False'
}
We can also use the .NET's string extension function StartsWith to check whether a string is startswith a set of characters. The following method is used to check if a string is start with other string.
$strVal ='Hello world'
if($strVal.StartsWith('Hello')) {
     Write-Host 'True'
} else {
     Write-Host 'False'
}
Use the following method if you want to ignore the case in start with check.
$strVal ='Hello world'
if($strVal.StartsWith('hello','CurrentCultureIgnoreCase')) {
     Write-Host 'True'
} else {
     Write-Host 'False'
}

Monday, 22 August 2016

Complete List of SharePoint List Template IDs

This post list the complete SharePoint List Templates and IDs. You should know the template id for every type of list to differentiate all the lists. When you work with client side object models(CSOM) or any other scripting technology, this template id will be used to filter the specified type of lists (i.e. if you want to get all the asset library lists, you need to filter the lists by the template id 851).

Template Type Id Description
100 Generic List
101 Document Library
102 Survey List
103 Links List
104 Announcements List
105 Contacts List
106 Events List
107 Tasks List
108 Discussion Board
109 Picture Library
110 DataSources List
111 WebTemplate Catalog
112 UserInformationList
114 ListTemplate Catalog
113 WebPart Catalog
115 XmlForm Library
116 MasterPage Catalog
117 NoCode Workflows
118 Workflow Process
119 WikiPage Library
120 Grid List
121 SolutionCatalog
122 NoCode Workflows Public
123 Theme Catalog
130 DataConnection Library
140 Workflow History
150 Gantt Tasks
151 Help Library
200 Meetings List
201 MeetingAgenda List
202 MeetingAttendees List
204 MeetingDecision List
207 MeetingObjectives List
210 MeetingTextBox
211 MeetingThingsToBring List
212 MeetingHomePage Library
301 BlogPosts List
302 BlogComments List
303 BlogCategories List
400 ScheduleAndReservations
401 ManageResources List
402 Resources List
403 Whereabouts List
404 CallTrackingPhoneMemo
405 Circulation
420 Timecard
421 Holidays
432 KPIStatus List
433 Report Library
450 PerformancePointContent List
460 PerformancePointDataSource Library
470 PerformancePointDataConnections Library
480 PerformancePointDashboards Library
499 MicrosoftIMEDictionary List
505 VisioProcessDiagram Library (Metric)
506 VisioProcessDiagram Library (US Units)
600 External List
850 Pages Library
851 Asset Library
1100 IssueTracking List
1200 AdministratorTasks List
1220 Health Rules
1221 Health Reports
1300 TranslationManagement Library
1301 LanguagesAndTranslators List
1302 Record Library
2002 PersonalDocument Library
2003 PrivateDocument Library
2100 Slide Library

Thursday, 18 August 2016

Export Office 365 Email Addresses to CSV using Powershell

In this post, I am going write steps to export the list of exchange online users and their email addresses from Office 365 to csv file. We can use the powershell cmdlet Get-Mailbox to get mailbox information and use the cmdlet Export-CSV to export content to csv file.

Note: Before proceed, Connect Exchange Online Remote PowerShell.

Then run the below powershell command to list the mailbox users and its primary email address.
Get-Mailbox -ResultSize Unlimited |Select-Object DisplayName,PrimarySmtpAddress
The following command export all the exchange online users and its associated email addresses to csv file.
Get-Mailbox -ResultSize Unlimited |
Select-Object DisplayName,PrimarySmtpAddress, @{n="EmailAddresses";e={$_.EmailAddresses |
Where-Object {$_ -like "smtp*"} | ForEach-Object {$_.Substring(5)}}} | 
Export-Csv "C:\\o365-email-addresses.csv" -NoTypeInformation -Encoding UTF8

Thursday, 11 August 2016

Convert a distribution group to an Office 365 group from Admin Center

Finally, the support for migrating Distribution list to Office 365 group comes to live through Office 365 Admin center. The introduction of Office 365 groups gives the next level for cloud first and mobile first agenda since it gives the rich collaboration experiences.

The office 365 group is the next generation type of group that replaces the function of a traditional distribution list, and it includes the benefits of a security group, along with many other rich collaboration that enables teams to come together and establish a single team identity and a single set of permissions across different Office 365 apps including Outlook, Planner, OneNote,OneDrive, Skype for Business, etc.

Using new DL migration option, you can now migrate a distribution group to an Office 365 group directly from the Exchange Admin Center.

For more details read this thread: https://network.office.com/t5/Exchange/Migrate-a-distribution-group-to-an-Office-365-group-with-one/m-p/4340/highlight/true#M81

migrate a distribution list to an Office 365 groupr

Wednesday, 10 August 2016

Export Office 365 Users to CSV using PowerShell

We can easily export users using Office 365 Admin center UI, but in this way we can get only set of attributes and we can't easily filter our required set of users. In this article, I am going to write powershell script to export all office 365 users and export only licensed users to csv file.

Note: Before proceed, Install and Configure Azure AD PowerShell

Use the below command to export all the office 365 users. You can add more columns to export.
Get-MsolUser -All  | Select-Object UserPrincipalName, DisplayName, isLicensed |
Export-CSV "C:\\all-office-365-users.csv" -NoTypeInformation -Encoding UTF8
In some scenarios, you might want to get details of only licensed office 365 users. To get only licensed users, you need to apply where filter in the output of Get-MsolUser cmdlet.
Get-MsolUser -All | Where-Object { $_.isLicensed -eq ”TRUE” } | 
Select-Object UserPrincipalName, DisplayName, Department  |
Export-CSV "C:\\licensed-office-365-users.csv" -NoTypeInformation -Encoding UTF8
You can also extract what are the licenses has been assigned to every users. The below command export all the licensed users and applied license details to csv file.
Get-MSOLUser -All | Where-Object { $_.isLicensed -eq ”TRUE” } | 
Select-Object UserPrincipalName, DisplayName, {$_.Licenses.AccountSkuId} |
 Export-CSV "C:\\office-365-users-license.csv" -NoTypeInformation -Encoding UTF8
Note: Checkout this post ( Manage Office 365 License using Powershell ) to add a new license, remove an existing license and update existing license options (enable or disable license plans) using PowerShell command.

Thursday, 4 August 2016

Mailbox : WhenCreated vs WhenMailboxCreated

You should have noticed the two attributes WhenCreated and WhenWhenMailbox while fetching the information through powershell using the cmdlet Get-Mailbox. The WhenMailboxCreated attribute shows the time when the mailbox was created or license assigned (in office 365). On the other side, the WhenCreated attribute gives time when the mailbox associated AD user or Azure AD user was actually created. So, the value of these two attributes may or may not equal.

WhenMailboxCreated : Gives the time when the mailbox was created.

WhenCreated : The time of when the AD user or Azure AD user of the associated mailbox was created.

So, if you want to get the list of mailboxes that are created in last 7 days. You need to use following powershell command.
Get-Mailbox | Where-Object {$_.WhenMailboxCreated –ge ((Get-Date).Adddays(-7))}
You may get incorrect results when you use whencreated to get mailboxes that are created in past N days. But, you can use below command to get actual AD users who are created in last 7 days.
Get-Mailbox | Where-Object {$_.WhenCreated –ge ((Get-Date).Adddays(-7))}