#sharepoint csom create new list item
Explore tagged Tumblr posts
softreetechnology-blog · 6 years ago
Text
Identify The Modern Pages And Copy Them To Another Site Collection
In this blog, I am going to perform two actions -
Identify if a page is a modern page or not.
Migrate or copy that modern page (including its content) to another site collection or site (destination location)
I am going to accomplish these tasks by using CSOM (Client Object Model). After identifying the modern page, I will copy the modern page into another site collection (destination location) and then, will migrate all the page contents of this modern page (including web parts and other properties of source modern page) to a destination web using CSOM. We are using a console application to achieve the above functionality using CSOM. In the below-mentioned code logic, we will get all pages from ‘Site Pages’ page library which is present in the source web and looping each page to check if that is a modern page or not. If the page is found to be a modern page, then we are migrating that page to the destination web ‘Site Pages’ library. Please have a look at the below code. The code is self-explanatory because of the comments.
using System;
using System.Net;
using System.Security;
using System.Text.RegularExpressions;
using Microsoft.SharePoint.Client;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
ClientContext sourceContext = null;
List sourceList = null;
ListItemCollection srcItemCollection = null;
ListItem sourceItem = null;
string userName = string.Empty;
string password = string.Empty;
SecureString srcSiteSecurePassword = new SecureString();
SharePointOnlineCredentials sourceOnlineCredentials = null;
try {
using(sourceContext = new ClientContext("http://sourcesiteurl")) {
userName = "TestUser";
password = "Password";
if (!string.IsNullOrEmpty(password)) {
foreach(char c in password.ToCharArray())
srcSiteSecurePassword.AppendChar(c);
}
// Setting credential for the above site
sourceOnlineCredentials = new SharePointOnlineCredentials(userName, srcSiteSecurePassword);
sourceContext.Credentials = sourceOnlineCredentials;
sourceContext.Load(sourceContext.Web);
sourceContext.ExecuteQuery();
// Getting source list by Title
sourceList = sourceContext.Web.Lists.GetByTitle("Site Pages");
// Getting all items from source list using caml query
srcItemCollection = sourceList.GetItems(CamlQuery.CreateAllItemsQuery());
//Loading source items
sourceContext.Load(srcItemCollection, IC => IC.Include(I => I.Id, I => I.DisplayName));
sourceContext.ExecuteQuery();
if (srcItemCollection != null && srcItemCollection.Count > 0) {
for (int iCount = 0; iCount < srcItemCollection.Count; iCount++) {
try {
sourceItem = srcItemCollection[iCount];
//Checking if current page is modern page or not
if (IsModernPage(sourceContext, sourceItem)) {
// Migrate modern page to anothen site
MigrateModernPageToAnotherWeb(sourceContext, sourceItem);
}
} catch (Exception ex) {}
}
}
}
} catch (Exception ex) {}
}
// Checking if the selected page is a modern page or not
private static bool IsModernPage(ClientContext sourceContext, ListItem sourceItem) {
bool isModernPage = false;
try {
sourceContext.Load(sourceItem, srcItm => srcItm["CanvasContent1"], srcItm => srcItm["LayoutWebpartsContent"]);
sourceContext.ExecuteQuery();
// Check if modern page
if (!string.IsNullOrEmpty(sourceItem["CanvasContent1"].ToString()) || !string.IsNullOrEmpty(sourceItem["LayoutWebpartsContent"].ToString())) isModernPage = true;
} catch {
isModernPage = false;
}
return isModernPage;
}
// Migrating the modern page from source site to destination site
private static void MigrateModernPageToAnotherWeb(ClientContext sourceContext, ListItem sourceItem) {
ClientContext destSiteContext = null;
List destList = null;
ListItem destItem = null;
string userName = string.Empty;
string password = string.Empty;
SecureString destSiteSecurePassword = new SecureString();
SharePointOnlineCredentials destOnlineCredentials = null;
string canvasContent = string.Empty;
string metaInfo = string.Empty;
string layoutWebpartsContent = string.Empty;
try {
using(destSiteContext = new ClientContext("http://destinationsiteurl")) {
userName = "TestUser";
password = "Password";
if (!string.IsNullOrEmpty(password)) {
foreach(char c in password.ToCharArray())
destSiteSecurePassword.AppendChar(c);
}
// Setting credential for the above site
destOnlineCredentials = new SharePointOnlineCredentials(userName, destSiteSecurePassword);
destSiteContext.Credentials = destOnlineCredentials;
destSiteContext.Load(destSiteContext.Web);
destSiteContext.ExecuteQuery();
// Getting destination list by Title
destList = destSiteContext.Web.Lists.GetByTitle("Site Pages");
// Loading destination list
destSiteContext.Load(destList, L => L.RootFolder.ServerRelativeUrl);
destSiteContext.ExecuteQuery();
// Creating modern page in destination site
destItem = destList.RootFolder.Files.AddTemplateFile(destList.RootFolder.ServerRelativeUrl.TrimEnd('/') + "/" + sourceItem.DisplayName + ".aspx", TemplateFileType.ClientSidePage).ListItemAllFields;
destSiteContext.Load(destItem);
destSiteContext.ExecuteQuery();
// Loading source item properties
sourceContext.Load(sourceItem, i => i.ContentType.Id, i => i["CanvasContent1"], i => i["MetaInfo"], i => i["LayoutWebpartsContent"]);
sourceContext.ExecuteQuery();
try {
destItem["ContentTypeId"] = sourceItem.ContentType.Id.ToString();
canvasContent = sourceItem["CanvasContent1"].ToString();
// Replacing source Web ID with destination Web ID
if (!string.IsNullOrEmpty(canvasContent) && canvasContent.Length > 0 && canvasContent.ToLower().Contains(sourceContext.Web.Id.ToString().ToLower())) canvasContent = Regex.Replace(canvasContent, sourceContext.Web.Id.ToString(), destSiteContext.Web.Id.ToString(), RegexOptions.IgnoreCase);
} catch (Exception ex) {}
try {
metaInfo = sourceItem["MetaInfo"].ToString();
// Replacing source Web ID with destination Web ID
if (!string.IsNullOrEmpty(metaInfo) && metaInfo.Length > 0 && metaInfo.ToLower().Contains(sourceContext.Web.Id.ToString().ToLower())) metaInfo = Regex.Replace(metaInfo, sourceContext.Web.Id.ToString(), destSiteContext.Web.Id.ToString(), RegexOptions.IgnoreCase);
} catch (Exception ex) {}
try {
layoutWebpartsContent = sourceItem["LayoutWebpartsContent"].ToString();
// Replacing source Web ID with destination Web ID
if (!string.IsNullOrEmpty(layoutWebpartsContent) && layoutWebpartsContent.Length > 0 && layoutWebpartsContent.ToLower().Contains(sourceContext.Web.Id.ToString().ToLower())) layoutWebpartsContent = Regex.Replace(layoutWebpartsContent, sourceContext.Web.Id.ToString(), destSiteContext.Web.Id.ToString(), RegexOptions.IgnoreCase);
} catch (Exception ex) {}
// Setting source page canvas content to destination page
if (!string.IsNullOrEmpty(canvasContent) && canvasContent.Length > 0) destItem["CanvasContent1"] = canvasContent;
// Setting source page metaInfo content to destination page
if (!string.IsNullOrEmpty(metaInfo) && metaInfo.Length > 0) destItem["MetaInfo"] = metaInfo;
// Setting source page layout webparts content to destination page
if (!string.IsNullOrEmpty(layoutWebpartsContent) && layoutWebpartsContent.Length > 0) destItem["LayoutWebpartsContent"] = layoutWebpartsContent;
// Updating the destination page
destItem.Update();
destSiteContext.ExecuteQuery();
}
} catch (Exception ex) {}
}
}
}
Destination Page Library Before Migration: –
Tumblr media
Destination Page Library after Migration:-
Tumblr media
After executing the above code behind, you can find the newly created modern page in the destination web ‘Site Pages’ library with the same page contents and “web parts” as they were in the source page.
This solution is brought to you by our SharePoint professionals.
Softree Consulting employs SharePoint consultants; we are a technology services provider with the aim to help companies achieve exceptional performance through SharePoint. Our dedicated team of SharePoint consultants has the right bent of mind to understand and execute customer requirements.
Be it SPFx or SharePoint add-in developments, SharePoint 2019 developments, web part developments, migrating from SharePoint 2010/2013 to SharePoint 2013/2016/Office 365, Office 365, SharePoint hosted apps development or something else in SharePoint, we strive to deliver the best
0 notes
dbpmsnews · 7 years ago
Text
Modernize your SharePoint team sites by connecting them to new Office 365 groups
SharePoint powers content collaboration in Office 365. At work, it is important for every team member to streamline efforts and stay on the same page. Group-connected SharePoint team sites provide a central location to manage team files, input and connect to important data, and s...
"Modernize your SharePoint team sites by connecting them to new Office 365 groups" by Mark Kashman originally published June 6th 2018 in Microsoft SharePoint Blog articles
SharePoint powers content collaboration in Office 365. At work, it is important for every team member to streamline efforts and stay on the same page. Group-connected SharePoint team sites provide a central location to manage team files, input and connect to important data, and share timely news. With insight into what drives the most engagement and value, people can course correct and optimize for greatest impact.
  Users have been adopting modern SharePoint lists and libraries and creating modern pages. And now it’s time to bring the full power of SharePoint and Office 365 to all your sites. We’re excited to announce that you can now further modernize your existing (classic) sites by connecting them to new Office 365 groups.
Tumblr media
  It is easy to connect your existing SharePoint site to a new Office 365 group. [30-second looping GIF]
This connection also allows you to associate your site to a SharePoint hub site now that it has a modern home page, and the site will look and function better via the SharePoint mobile app.
  Connect your existing SharePoint sites to a new Office 365 group
You can connect your site to a new Office 365 group from the user interface site-by-site, which might be good for smaller environments. However, larger customers often want to offer a consistent experience to their users, and therefore want to perform a bulk operation of their sites. Last month, we made tools available for admins to connect existing sites to new Office 365 Groups.
  Being able to connect an Office 365 group to an existing SharePoint site is important if you want to modernize that site and provide additional group capabilities to all team members. In addition to using modern pages, lists and libraries already available in your classic sites, once you have connected your site to an Office 365 group, it can benefit from all other shared group-connected apps such as Outlook for a group inbox and calendar, Planner for task management, Microsoft Teams for real-time, persistent chat, and more.
  Now, we are expanding this capability to site owners directly from the team sites they own and manage.  When enabled in your environment, it’s easy to get started.  As a site owner, you can initiate the group connection by selecting Connect to new Office 365 Group from the upper-right site gear menu. Note: if this does not appear, either your tenant does not yet have this capability as it takes several weeks to roll out to all customers, or you are not a site owner of that site.
Tumblr media
  From an existing (classic) SharePoint site, select "Connect to a new Office 365 Group" from the upper-right gear icon menu to start the process.
This will launch an experience that will guide you step-by-step through the group connection process, where you provide details for the new Office 365 group, including name, email address, members and owners.  Upon completion, you will be presented with a new, modern home page created for your site with a new, editable page with new web parts to get you started– including a site activity web part that highlights relevant content actions occurring within your site. The page also includes a new link to the group’s inbox in the left navigation and a header with relevant group information and membership. Plus, when you hover on the team site name at the top, you will see the new group car that gives quick access to other apps and shows more about the group and what’s happening beyond the site.
  Rest assured that all your previous content remains in the site, and a link to the previous home page is also added to the site’s navigation. No site left behind, AND no content left behind. Just moving forward!
Tumblr media
  After stepping through a few wizard-driven steps to add members and owners and adjust settings if needed, you'll be presented with an updated site connected to Office 365 group apps.
Beyond your content, all existing permissions in the site remain the same as well.  This ensures that anyone that had access to resources in the site will continue to have them once it is group connected.
Tumblr media
    The updated Site permissions experience is available to site owners from the upper-right gear icon menu to allow inline management of site permissions and invite others to collaborate.
  Get started today!
There is no reason to delay. Start your modernization journey now.  Get the most out of the power of SharePoint and Office 365 Groups to boost people productivity across your company.
  SharePoint powers content collaboration for the modern workplace, enabling teamwork with team sites connected to Outlook, Microsoft Teams, Planner and more. Whether you call this ‘site modernization,’ ‘groupify’ or ‘no site left behind’ - start connecting your existing SharePoint sites to new Office 365 groups today! You’ll jump for joyify for sure.
  Thanks,
Mark Kashman and Tejas Mehta, SharePoint team - Microsoft
  FAQs and additional, related resources below…
  Frequently Asked Questions (FAQs)
Q: How can I expect connecting existing SharePoint sites to new Office 365 Groups to roll out to Office 365 customers?
A: The ability to connect existing SharePoint sites to new Office 365 Groups Communication sites will begin to roll out to all Targeted Release customers this week, and will be completed within 2–3 weeks. We then are targeting end of July 2018 for complete worldwide roll out into production.
  Q: What types of sites can I connect to new Office 365 Groups?
A: You can connect top-level site collections that use the team site web template (also known as STS#0). You cannot group-connect subsites.
  Q: What permissions do I need to have to connect my existing site to a new group?
A: Site collection administrators of the existing SharePoint site have the appropriate permissions to initiate the group connection process from the upper-right gear icon menu.  Global admins can use PowerShell cmdlet or API tools as well.
  Q: What if my site has items with unique permissions?  Do they change?
A: The group connection process does not change permissions on items with unique permissions. 
  Q: Can I limit the availability of this feature to just my global admins?
A: Yes, there is an admin setting that lets you control whether this feature is available for site administrators from the gear menu.
  Additional resources
Support page for connecting classic SharePoint team sites to Office 365 Groups
Administrator documentation, which includes instructions on changing the user interface availability for this feature
SharePoint modernization scanner tool to prepare your classic team sites for modernization
PowerShell cmdlet documentation for Set-SPOSiteOffice365Group
API documentation:
Overview of the "Connect to new Office 365 group" feature
Connect to an Office 365 Group
Connect to new Office 365 group: CSOM development
Previously disclosed at Ignite 2017: https://techcommunity.microsoft.com/t5/SharePoint-Blog/Work-better-together-with-SharePoint-team-sites-Office-365-app/ba-p/109550
Ignite 2017 session on-demand, “No team site left behind!”
Read Full Post
0 notes
lyncnews · 8 years ago
Link
This year I set myself a little project to see if I could use some of the tools and platforms provided in Office 365 to create something mildly useful. I wanted to start with something basic and achievable without having to spend months and months of trial and error experiments and thought that Phone Number management could be that starter project.
I will preface this blog by stating that there are already various number management solutions out there, some paid and some free and this hasn’t been created to compete with them. It is a project that enables me to learn and develop new skills but also has some use cases that may benefit you, hence the reason for sharing.
Often when I speak with customers and ask them about their number management solution, they invariably say Excel. They’d like to move towards a more suitable product but those offering these solutions are sometimes out of reach of the budget available. Using a basic Excel sheet has it’s own problems, but mainly keeping the thing up to date with all adds, moves and changes. So I thought there must be a way to leverage what is available in just an E1 Office 365 licence to create a middle ground. Something in between Excel and the paid apps must surely be possible?
So I looked at Lists in SharePoint Online. This seemed the logical choice in the Office 365 product suite to use a my “database” as it where. Out of the box it had a lot of built in features that meant I could save time by not having to create user interfaces, search filters and different views. It also acts like Excel so that you can easily update multiple records in-line and provide a single pane of glass experience without having to install any software on to a bunch of admin workstations. However, a SharePoint List on it’s own is probably no better than that Excel sheet stored on a file share somewhere. It needed a way in which admins can interact with it and easily use in day to day tasks. More importantly it needed a way to talk to Skype for Business to ensure that the list kept was the single, undisputed source of truth.
What it needed was a PowerShell Module to bridge the gap between SharePoint Online and Skype for Business. I then found that the SharePoint Online Management Shell allowed management of tasks, but offered no way to interact or manipulate the data held within SharePoint. I quickly learned that in order for me to manipulate data I needed to use the Client Side Object Model (CSOM) for SharePoint Online.
Enter first problem. I know nothing about CSOM. Worse still I seem to have a mental block in understanding how to code in .Net or C#, but I can do some basic PowerShell. I am glad to say that this was quickly resolved with the thanks to Arleta Wanat (a SharePoint MVP) who had already create her own PowerShell module for manipulating data within SharePoint Online. A great set of commandlets that everyone should have in their back pocket. You can download the module here: http://ift.tt/2n3os3A
I thought all my birthdays had come at once with this module, until I found some limitations to some of the functions I was using. Mainly these where down to the size of the data being extracted from SharePoint Online in order to return my custom list fields, and the dreaded 5,000 item view limit of SharePoint Online!
So I had to customise it slightly to allow me to continue as it worked really well for 5,000 phone numbers but failed miserably with 5,001! Having overcome this, the theoretical maximum this can handle if somewhere in the region of 50,000,000 (Yes, 50 million) phone numbers.
Key Features
I am pretty sure right now, you don’t want a life story of development, but rather want to know what does this thing do, right?
Skype for Business On-Prem and Cloud PBX Support
Firstly, this works for Skype for Business On-Prem and Skype for Business Online (Cloud PBX) so you’re covered in all three states (On-Prem, Hybrid and Cloud Only).
Synchronizes Phone Numbers
Whether you run Skype for Business Server or Cloud PBX or Both you can synchronize numbers from these systems into the Phone Inventory List. All Cloud PBX numbers will be synchronized whether they are subscriber or service numbers. If they are assigned to a service or user, then this information is passed back to the list so that it immediately understands the allocation landscape. The same for On-Prem, synchronization happens and retrieves all used numbers within the ecosystem for users, conference, RGS, Trusted Applications etc etc. Again passing back their assignments.
Integration with Numverify
For On-Prem numbers it can be hard sometimes to gather a list of cities, countries and even carriers each phone number relates to. If you don’t have this information to hand, then the task of finding this out can be arduous. Therefore, there is integration with the numverify api (https://numverify.com/)  which will search for this information and retrieve it automatically when you synchronize or import your numbers. The API is free to use (up to a max of 250 calls per month) and requires you to sign up for an account for your own personal API key.
PowerShell Module
The PowerShell module is the beating heart of all this. There are several commandlets that give admins the power to allocate numbers to users individually or in bulk as well as allow you to reserve a number or a block of numbers so that they cannot be used unless specifically chosen. This is useful for planning projects that require a bank of numbers to be allocated but not yet assigned in Skype for Business. There are also commandlets that allow you to import numbers from a CSV, or just by stating the start number and how many numbers in sequence you want to add.
PowerBI
If you want to produce graphs on consumed numbers per area, per usage, per site etc. This can all be done in PowerBI with a live data connection to the SharePoint list. PowerBI free is sufficient, but you will need the PowerBI desktop app to create the data connection.
Mobile support using PowerApps
Want to be able to quickly reserve or assign a number to a user? Maybe add one that you forgot whilst on the train home? No problem, easily create a mobile app using PowerApps and you can manage your DDIs wherever you are.
Requirements
An active Office 365 E1 licence subscription assigned to each admin account
Each admin must have at least contribute permission on the SharePoint list
Each admin must have Skype for Business Online Admin permission if you are using Cloud PBX
Each admin must have at least Voice Administrator permission on Skype for Business On-Prem
The SharePoint Online Client Side Components must be installed on the machine the PowerShell module is going to be run on
Skype for Business Management components required on the machine the module is going to be run on
Skype for Business Online Management Shell installed on the machine the module is going to be run on
SharePoint Site Collection and Site (not required to be dedicated)
PowerShell Commands
Connect-MyPhoneInventory
You must use this command at the beginning of each session to establish a connected session to SharePoint Online, Cloud PBX and Skype for Business Server. The command accepts four mandatory parameters. When connection has been established, a full copy of the SharePoint List will be downloaded into memory to enable faster access to the subsequent commands used in the session. Please be aware that as the list grows, the longer it will take to download the list. Estimate performance to be around one minute per 5,000 numbers.
Parameters
-Username [string]
-Password [string]
-Url [string]
-ConnectOnline [bool]
Usage
Connect-MyPhoneInventory –Username [email protected] –Password <mypassword> –Url http://ift.tt/2mIZVVn –ConnectOnline $true | $false
Sync-Cache
This command you can use to update your local cache based on the data held on SharePoint. This is useful in case the local cache becomes inconsistent, or something happens where the cache is lost. This command accepts no parameters.
Usage
Sync-Cache
Get-Cache
This command you can use to bring the cache out of the private data area into a custom variable you can use for other commandlets not included in this module. This commandlet accepts no parameters
Usage
$Data = Get-Cache
Get-MyNextNumber
This command gets the next available number(s) from the pool in which you specify. When executed, this command will put a “soft” reserve on the numbers returned. This allows you to assign numbers to bulk users in your scripts without having to synchronize with SharePoint after each one. Please be aware that after you have finished using this command you should perform a Sync-Cache to return an accurate copy of the list if no changes have been made in Skype for Business / Cloud PBX. If there have been, a full Skype for SharePoint synchronization is required.
Parameters
-Area [string][optional] – The Area / City to get the next number from
-Carrier [string][optional] – The carrier from which to get the next number from
-NumberType – [string][optional] [valid types] – Subscriber, Conference, RGS, Service, Private
-Block – [num][optional] – The number of free numbers to return in the result
Usage
Get the next 10 numbers available in the town called Crewe where the Carrier is BT and the Number is a Subscriber.
Get-MyNextNumber -Area Crewe -Carrier BT -NumberType Subscriber -Block 10
Get-MyNextNumber on it’s own returns the next available number in the list based on ID
Get-MyAvailableNumber
This command returns all the available numbers in the pool in which you specify.
Parameters
-Area [string][optional] – The Area / City to get the next number from
-Carrier [string][optional] – The carrier from which to get the next number from
-NumberType – [string][optional] [valid types] – Subscriber, Conference, RGS, Service, Private
Usage
Get-MyAvailableNumber -Area Crewe -Carrier BT -NumberType Conference | Format-Table
Count-MyAvailableNumber
This command returns a count of all the available numbers in the pool in which you specify.
Parameters
-Area [string][optional] – The Area / City to get the next number from
-Carrier [string][optional] – The carrier from which to get the next number from
-NumberType – [string][optional] [valid types] – Subscriber, Conference, RGS, Service, Private
Usage
Count-MyAvailableNumber -Area Crewe -Carrier BT -NumberType Conference
Reserve-MyNumberRange
This command allows you to reserve numbers in ranges from 1 to unlimited, or by number type and how many based on area.
Parameters
-StartNumber [number] must be in E164
-EndNumber [number] must be in E164
-Area [string][optional] – The Area / City to get the next number from
-NumberType – [string][optional] [valid types] – Subscriber, Conference, RGS, Service, Private
Usage
Reserve-MyNumberRange -StartNumber +441270212000 -EndNumber +4412702121000
Or
Reserve-MyNumberRange -Area Crewe -NumberType Subscriber -BlockTotal 500
Count-MyReservedNumber
This command allows you to count how many numbers are reserved but not assigned yet in the pool in which you specify. This is useful for identifying number that require  scavenging / recycling back into the available pool.
Parameters
-Area [string][optional] – The Area / City to get the next number from
-Carrier [string][optional] – The carrier from which to get the next number from
-NumberType – [string][optional] [valid types] – Subscriber, Conference, RGS, Service, Private
Usage
Count-MyReservedNumber -Carrier BT
Get-MyReservedNumber
This command outputs all the reserved numbers in your chosen selection
Parameters
-Area [string][optional] – The Area / City to get the next number from
-Carrier [string][optional] – The carrier from which to get the next number from
-NumberType – [string][optional] [valid types] – Subscriber, Conference, RGS, Service, Private
Usage
Get-MyReservedNumber -Area Crewe | Format-Table
Get-MyNextReservedNumber
This command returns the next unallocated reserved number in your selection
Parameters
-Area [string][optional] – The Area / City to get the next number from
-Carrier [string][optional] – The carrier from which to get the next number from
-NumberType – [string][optional] [valid types] – Subscriber, Conference, RGS, Service, Private
-Block [int] – the number of numbers to return
Usage
Get-MyNextReservedNumber -Area Crewe -Carrier BT -NumberType Service -Block 10
Release-MyReservedNumber
This command is used to release reserved numbers that will not be allocated to a user or service back into the available pool.
Parameters
-StartNumber [number] – Must be in E164 format
-EndNumber [number] – Must be in E164 format
-Area [string][optional] – The Area / City to get the next number from
-Carrier [string][optional] – The carrier from which to get the next number from
-NumberType – [string][optional] [valid types] – Subscriber, Conference, RGS, Service, Private
-BlockTotal [int] How many numbers to release
-Site [string] – The site the numbers belong to
Usage
Release-MyReservedNumber -StartNumber +441270212000 -EndNumber +441270212500
Or
Release-MyReservedNumber -Area Crewe -NumberType Subscriber -BlockTotal 500
Or
Release-MyReservedNumber -Site ManchesterOffice -NumberType Service -BlockTotal 100
Count-MyUsedNumber
This command returns a count of all used numbers within the pool chosen
Parameters
-Area [string][optional] – The Area / City to get the next number from
-Carrier [string][optional] – The carrier from which to get the next number from
-NumberType – [string][optional] [valid types] – Subscriber, Conference, RGS, Service, Private
Usage
Count-MyUsedNumber -Area Crewe -Carrier BT -NumberType Service
Get-MyUsedNumber
This command returns a list of all used numbers within the pool chosen
Parameters
-Area [string][optional] – The Area / City to get the next number from
-Carrier [string][optional] – The carrier from which to get the next number from
-NumberType – [string][optional] [valid types] – Subscriber, Conference, RGS, Service, Private
Usage
Get-MyUsedNumber -Area Crewe -Carrier BT -NumberType Service | Format-Table
Sync-MyNumbersFromSkype
This command gathers all the allocated numbers within Skype for Business Server and uploads them to the SharePoint List. This command also updates the assignments to users and other services that may use numbers. It is recommended that you create a schedule task to run this command at least once per day during quiet times to ensure that the list remains current and up to date.
Parameters
-UserNumbers [bool] [optional] $true | $false
-ConferenceNumbers [bool] [optional] $true | $false
-PrivateNumbers [bool] [optional] $true | $false
-RgsNumbers [bool] [optional] $true | $false
-ServiceNumbers [bool] [optional] $true | $false
Usage
Sync-MyNumbersFromSkype
Use parameters only if you want to synchronize a sub portion of numbers based on type.
Import-MyNumberBlock
This command allows you to add new numbers to the SharePoint List from a CSV File
Parameters
-Path [string] – Path to CSV file
Usage
Import-MyNumberBlock -Path C:NumbersMyNumbers.csv
Please note that columns in the CSV should be named as follows:
Number – The full phone number in E164 format
Exten – The extension number
Carrier – The name of the Carrier
Type – The Number Type i.e. Subscriber, Service, Conference, Rgs, Private
Country – The country of origin
Area – The city / town or area
Reserved – Yes or No
Site – Site where the number terminates
User – The SIP address of the user assigned to the number – must match sip:[email protected]
Residency – The system type, e.g. On-Prem or Online
Export-MyNumberBlock
This command allows you to export the data from the SharePoint list to a CSV. The default behaviour is to export from the current data held in memory.
Parameters
-ExportPath [string] [mandatory] – The path where the file will be saved
-FromSharePoint [bool][default $false] [optional] $true
Usage
Export-MyNumberBlock -ExportPath C:NumbersMyNumbers.csv
Or
Export-MyNumberBlock -ExportPath C:NumbersMyNumbers.csv -FromSharePoint $true
Add-MyNewNumberBlock
This command allows you to add sequential number blocks to SharePoint without a CSV. If you don’t know the area, country or carrier of the numbers, then you can use numverify to retrieve these.
Parameters
-StartNumber [number] [mandatory] – Must be in E164 format
-BlockTotal [int] [mandatory] – number of sequential numbers to add
-NumberType [optional][valid options] Subscriber,Conference, RGS, Service, Private
-Area [string][optional] – The city town or area of the number’s residence
-Country [string][optional] – The country the number belongs to
-Carrier [string][optional] – The name of the carrier
-ExtensionLength [int][optional][default = 4] – The extension length (taken from last X of DDI. Default is 4 if none specified)
-Site [string][optional] – The name of your site where the number terminates
-Reserved [bool][optional] – Should the number be immediately reserved. Values $true | $false
-Residency [string][mandatory][valid options] – On-Prem,Online
Usage
Add-MyNewNumberBlock -StartNumber +441270212000 -BlockTotal 2000 -NumberType Subscriber -Area Crewe -Country "United Kingdom" -Carrier BT -ExtensionLength 5 -Site CreweOffice -Reserved $False -Residency On-Prem
Or with numverify enabled
Add-MyNewNumberBlock -StartNumber +441270212000 -BlockTotal 2000 -NumberType Subscriber -ExtensionLength 5 -Site CreweOffice -Reserved $False -Residency On-Prem
If no results found, or numverify not enabled, then “unknown” will be entered in missed fields.
Remove-MyNumberBlock
This command removes numbers that are not allocated to users or services from the list
Parameters
-StartNumber [number] [mandatory] – Must be in E164 format
-BlockTotal [int] [mandatory] – number of sequential numbers to remove
Usage
Remove-MyNumberBlock - StartNumber +441270212000 -BlockTotal 1000
Show-MyNumberSummary
This command produces a summary of the current number allocation
Parameters
-Area [string][optional] – The Area / City to get the next number from
-Carrier [string][optional] – The carrier from which to get the next number from
-NumberType – [string][optional] [valid types] – Subscriber, Conference, RGS, Service, Private
Usage
Show-MyNumberSummary -Area Crewe
Or
Show-MyNumberSummary -Carrier BT
Or
Show-MyNumberSummary -NumberType Subscriber -Area Crewe -Carrier BT
Or
Show-MyNumberSummary
Sync-MyOnlineNumber
This command synchronizes Cloud PBX numbers to the list and updates assignments. It is recommended to create a scheduled task to run this command at least once per day to ensure the list is kept up to date. This command accepts no parameters
Usage
Sync-MyOnlineNumber
Get-MyOnlineNumberArea
This command is used to retrieve the Cloud PBX area allocation code which can be used to find available and reserve numbers. This command accepts no parameters
Usage
Get-MyOnlineNumberArea
Get-MyOnlineNextNumber
This command return the next available number(s) from Cloud PBX that have been acquired by your tenant. Please note that this command places a “soft” reserve on returned numbers so it an be used in a script. Please ensure that you run Sync-MyOnlineNumber command once finished to update the cache.
Parameters
-NumberType [string][mandatory][valid options] Subscriber, Service
-Area [string] – output of Get-MyOnlineNumberArea
-Block [int][optional] – Number of numbers to return
Usage
Get-MyOnlineNextNumber -NumberType Subscriber -Area EMEA-UK-ALL-ENG_CR -Block 10
Reserve-MyOnlineNumber
This command reserves Cloud PBX numbers in the list so they cannot be allocated.
Parameters
-NumberType [string][mandatory][valid options] Subscriber, Service
-Area [string] – output of Get-MyOnlineNumberArea
-Block [int][optional] – Number of numbers to return
Usage
Reserve-MyOnlineNumber -Area EMEA-UK-ALL-ENG_CR -NumberType Subscriber -Block 5
Release-MyOnlineReservedNumber
This command releases any reserved but not allocated numbers in the list that are Cloud PBX numbers.
Parameters
-NumberType [string][mandatory][valid options] Subscriber, Service
-Area [string] – output of Get-MyOnlineNumberArea
-Block [int][optional] – Number of numbers to return
Usage
Release-MyOnlineReservedNumber -Area EMEA-UK-ALL-ENG_CR -NumberType Subscriber -Block 10
Get-MyOnlineReservedNumber
This command return a list of all reserved numbers in the selection chosen
Parameters
-NumberType [string][mandatory][valid options] Subscriber, Service
-Area [string] – output of Get-MyOnlineNumberArea
-Block [int][optional] – Number of numbers to return
-All [bool][optional] – Set to $true if you want to return all reserved numbers regardless of type or area
Usage
Get-MyOnlineReservedNumber -All $true
Or
Get-MyOnlineReservedNumber -Area EMEA-UK-ENG_CR -NumberType Subscriber
Count-MyOnlineReservedNumber
This command returns a count of all numbers reserved in Cloud PBX
Parameters
-Area [string] – output of Get-MyOnlineNumberArea
-Block [int][optional] – Number of numbers to return
-All [bool][optional] – Set to $true if you want to return all reserved numbers regardless of type or area
Usage
Count-MyOnlineReservedNumber -All $true
Or
Count-MyOnlineReservedNumber -Area EMEA-UK-ENG_CR -NumberType Subscriber
Count-MyOnlineAvailableNumber
This command returns a count of all numbers available in Cloud PBX
Parameters
-Area [string] – output of Get-MyOnlineNumberArea
-Block [int][optional] – Number of numbers to return
-All [bool][optional] – Set to $true if you want to return all reserved numbers regardless of type or area
Usage
Count-MyOnlineAvailableNumber -All $true
Or
Count-MyOnlineAvailableNumber -Area EMEA-UK-ENG_CR -NumberType Subscriber
Count-MyOnlineUsedNumber
This command returns a count of all numbers in use in Cloud PBX
Parameters
-Area [string] – output of Get-MyOnlineNumberArea
-Block [int][optional] – Number of numbers to return
-All [bool][optional] – Set to $true if you want to return all reserved numbers regardless of type or area
Usage
Count-MyOnlineUsedNumber -All $true
Or
Count-MyOnlineUsedNumber -Area EMEA-UK-ENG_CR -NumberType Subscriber
Get-MyOnlineAvailableNumber
This command returns a list of all available numbers in Cloud PBX
Parameters
-Area [string] – output of Get-MyOnlineNumberArea
-Block [int][optional] – Number of numbers to return
-All [bool][optional] – Set to $true if you want to return all reserved numbers regardless of type or area
Usage
Count-MyOnlineAvailableNumber -All $true
Or
Count-MyOnlineAvailableNumber -Area EMEA-UK-ENG_CR -NumberType Subscriber
Installation
Install the sharepoint components in the Components Directory
Create a folder in your My Documents called WindowsPowerShell
Create a sub folder within this directory called Modules
Copy the PhoneInventory Folder and place it inside the Module folder you created above
In SharePoint Online click on Site Contents > Site Settings
Click on List Templates in the Web Designer Galleries
Click on the Files tab and click Upload Document
Browse to the SharePoint Online folder and select the PhoneInventory.stp file and press OK
Now go to your SharePoint Home Page and select Add lists, libraries and other apps
Find the app called PhoneInventory and click on it
You must call it PhoneInventory. No other name will work! Press Create
You should now be able to browse to your list
Enabling numverify Integration
To enable numverify integration, go to C:users<your name>documentswindowspowershellmodulesphoneinventory and open PhoneInventory.psm1. Around Line 13 you will see a variable $numverify that is commented out. Uncomment this variable and replace <your-key> with the API key given to you by numverify. Save the file and reload any open PowerShell windows.
Download
To download PhoneInventory please click here
Public BETA
This is currently in BETA. There may be bugs or features missing. If you come across any, please use the comment section below and I will work with you to get a stable release in the coming weeks / months.
0 notes