Getting Started: What are .ps1 files and how do you use them?

What is a .ps1 file?

powershell-ps1-cameron-dwyerIf you want to save a series of PowerShell commands in a file so you can run them again later then you effectively creating a PowerShell script. This is simply a text file with a .ps1 extension. The file contains a series of PowerShell commands, with each command appearing on a separate line.

Why would you use a .ps1 file?

When working with SharePoint I find that most of the time to achieve something useful I’m writing several lines of PowerShell with the result of each line feeding into subsequent lines. The scripts often end up resembling source code more than traditional command line input. So using .ps1 files work well, you simply write up the commands and then execute the .ps1 file to run all the commands, make changes re-run until you end up with a script that does what you want and you’ve ironed all the bugs out.

Saving your commands to a .ps1 file also makes them portable in that you can take the file onto another computer (another SharePoint server) and execute the same .ps1 file on it. By making use of input variables, input files, and prompting for user input you can craft .ps1 files that perform common functions and you can get a lot of reuse without having to change the commands within the .ps1 file.

How do you run a .ps1 file?

You can’t just double-click on a .ps1 file in Windows Explorer to run it. The most common way to run the .ps1 file in from a PowerShell Command window. The syntax differs a bit from the old command line.

You can either specify the entire path to the file such as:

c:\temp\myscript.ps1

Or if the current directory in the PowerShell window is set to the directory containing the .ps1 file you can use the .\ shortcut to execute the script:

.\myscript.ps1

That’s it for a very basic intro to .ps1 files, happy scripting!

More out-of-the-box ways to get Email into SharePoint (2013 and Office 365)

This is a continuation of an article I wrote back at the beginning of 2012 Five out-of-the-box ways to get Email into SharePoint. Since then we have seen the launch of SharePoint 2013 and also more widespread adoption of Office 365 (SharePoint Online). These more recent versions of SharePoint have introduced new ways of getting email into SharePoint and that’s what we will explore in the article.

Option 6 – Site Mailboxes

The Site Mailbox concept introduced in SharePoint 2013 promised a lot and sounded like it could be the primary option to go for when trying to integrate email and SharePoint. Rather than reproduce existing content here’s an article I wrote dedicated to SharePoint 2013 Site Mailboxes.

Pros

  • Site Mailboxes provide a consolidated view of site content stored within SharePoint and Exchange from within Microsoft Outlook
  • Minimal change with a familiar drag & drop process to the left navigation of Outlook. Allowing the capture of emails or email attachments into SharePoint and Exchange
  • Convenient access to SharePoint content from within Microsoft Outlook using a familiar metaphor of folders on the left navigation of Outlook.
  • Ability to include a Site Mailbox as an email recipient (e.g. cc’d) for saving emails into a Site Mailbox – Inbox
  • Ability to ‘Forward’ a link to a document within a Site Mailbox or drag/drop multiple documents into an email message.
  • Lifecycle Retention policies can be applied at a Site Mailbox level behind the scenes
    Management and Compliance: Site Mailboxes can be part of eDiscovery Search Scopes.
  • Minimal change for the end users and therefore greater user adoption and promotion of enterprise content management best practices
  • Less reliance on the IT Department once the SharePoint and Exchange environment have been configured for Site Mailboxes
  • More efficient means to support the business with records management initiatives
  • Streamlined provisioning and deployment of Site Mailboxes to end users based on security permissions within a SharePoint Site
  • Email content is retained within Microsoft Exchange while documents are retained within SharePoint

Cons

  • Setting up the environment to support Site Mailboxes involves installing and configuring software on both the Exchange and SharePoint servers and setting up trust relationships and having all communication over SSL.
  • Probably the biggest drawback is that you are not actually getting email into SharePoint. The email is stored in Exchange. This means you can’t treat it as a SharePoint object and include it as part of a business process. E.g. include it a part of a workflow, add metadata columns to email and build a SharePoint business process around it. I will add quickly that you can drag/drop email directly to a Document Library and this will get the email into SharePoint as an msg file.
  • You must be running SharePoint 2013, Exchange 2013 and Outlook 2013 to get access to Site Mailbox functionality
  • Very limited features on drag/drop of attachments to SharePoint document libraries – basically no support for metadata of any kind (no content type selection, no columns to complete, no validation of mandatory column, can’t rename files on upload, no support for versioning)
  • Viewing of SharePoint content is very limited. You are provided more with a file type view of content rather than a SharePoint view. You can’t show SharePoint columns in the Outlook view, you just get the filename, last modified, size, and checkout status.
  • Maximum of 10 Site Mailboxes can be added to Outlook

 

Further reading

http://camerondwyer.wordpress.com/2013/03/20/guide-to-setting-up-sharepoint-site-mailboxes-on-sharepoint-2013-and-exchange-2013/

http://camerondwyer.wordpress.com/2013/02/13/white-paper-sharepoint-2013-site-mailboxes/

http://blogs.technet.com/b/exchange/archive/2012/08/22/site-mailboxes-in-the-new-office.aspx

http://office.microsoft.com/en-001/sharepoint-help/overview-use-a-site-mailbox-to-collaborate-with-your-team-HA103927690.aspx

http://office.microsoft.com/en-001/office365-suite-help/prepare-for-using-site-mailboxes-in-office-365-HA103834109.aspx

 

Option 7 – Drag/Drop to SharePoint via Desktop

SharePoint 2013 provided the new capability of being able to drag and drop files from your computer directly into a SharePoint document library open in a browser window. Combine this with the ability to turn Outlook messages into msg files by dragging them of of Outlook onto the desktop and we have a fairly simple 2 step process.

Step 1: Drag email from Outlook and drop to the desktop

drag-drop-email-outlook-to-sharepoint-office365-drag-to-desktop-cameron-dwyer

Step 2: Drag email from the desktop and drop into SharePoint

drag-drop-email-outlook-to-sharepoint-office365-drag-to-sharepoint-cameron-dwyer

Thanks goes to Liz who posted a comment on this blog letting me know of this technique.

Pros

  • The email is stored in msg format so it can be opened back up in Outlook without loss of data or email integrity.
  • Once your windows are setup for source (Outlook) and destination (SharePoint) the drag drop is quite simple
  • No configuration or setup required and will work with any SharePoint 2013 document library
  • Can move multiple email at once
  • Can move attachments off email to SharePoint using same technique
  • Can save the the root of the SharePoint library or to a subfolder (just have the library open to the folder before the drag drop)
  • Will work with older versions of Outlook
  • Transfer happens in the background (SharePoint web browser provides progress bar)

Cons

  • Getting the Outlook and SharePoint windows accessible and seeing the desktop behind them to be able to execute the drag drop can be a bit fiddly so lends itself more to doing the transfers in batches rather than just ad-hoc when new email arrives.
  • No email attributes get captured/promoted to SharePoint columns

 

Further Reading

http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2012/07/16/how-to-drag-and-drop-files-into-sharepoint-2013-document-libraries.aspx

http://office.microsoft.com/en-us/office365-sharepoint-online-enterprise-help/upload-files-to-a-library-HA102803549.aspx

 

Option 8 – Save or Drag/Drop to a OneDrive Synced Location

OneDrive for Business is essentially a synchronization tool that lets you take a copy of a SharePoint library locally onto your machine. The document library appears in Windows Explorer as a folder with the documents appearing as files within the folder. Subfolders within a library are also supported. The nice thing about OneDrive is that it’s a 2 way sync. Any additional files you add to the local sync folder will get transferred up to SharePoint.

Step 1: Browse to your library in SharePoint and click on the sync button to have the SharePoint library sync’d via OneDrive to your local machine.

bulk-upload-folder-structure-sharepoint-cameron-dwyer-onedrive-sync-button

After the sync has completed the SharePoint library (and it’s content including any folder structure) is now represented as a folder structure that you can easily get to through Windows Explorer.

bulk-upload-folder-structure-sharepoint-cameron-dwyer-onedrive-local-library

Step 2: You can now open an Email in Outlook and choose to Save As and choose the OneDrive local folder as the save location. Alternatively you can open the OneDrive folder in Windows Explorer and drag/drop multiple emails directly from Outlook to the OneDrive folder. OneDrive will automatically upload these emails to SharePoint in the background.

Pros

    • The email is stored in msg format so it can be opened back up in Outlook without loss of data or email integrity.
      • Can move multiple email at once
      • Can move attachments off email to SharePoint using same technique
      • Can save the the root of the SharePoint library or to a subfolder (just have the library open to the folder before the drag drop)
      • Transfer happens in the background

Cons

  • Whole library must be synced locally which may mean a lot of files/data on the local machine that you don’t need or want
  • Using email Save As is tedious, drag and drop to OneDrive open in Explorer window is much nicer but it’s fiddly to get the windows visible to achieve the drag/drop so probably works better transferring in batches rather than as new email arrives.
  • No email attributes get captured/promoted to SharePoint columns

 

Further Reading

http://office.microsoft.com/en-001/sharepoint-help/sync-libraries-using-onedrive-for-business-HA103425074.aspx

http://camerondwyer.wordpress.com/2014/06/04/how-to-bulk-uploadcopy-a-folder-structure-and-files-to-sharepoint/

Beware SharePoint 2013 Search Results and the ListUrl Property

beware-caution-sharepointI was recently looking into the results returned by SharePoint 2013 under the scenario of alternate access mappings. Essentially this boils down to the same SharePoint content being available on different host URLs.

Here’s an example:

I can have a single site which I initially create on http://ourintranet, through the magic of alternate access mappings I can make the same SharePoint site also accessible on http://extranet.mycompany.com

SharePoint serves up exactly the same content irrespective of the URL host the user come in on. In the address bar of the users browser, the host portion of the URL remains constant as they navigate through the site e.g. if the user came in on http://extranet.mycompany.com they would not be switched over to the http://ourintranet host at any time.

These alternate access mappings carry across to search as well. The way this works is that the search processes will crawl the SharePoint site and index content based on one of the URLs (either http://ourintranet or http://extranet.mycompany.com, best practice is to use the access mapping of the default zone). When search results are requested the SharePoint server will find the matching results in it’s search index and then apply alternate access mappings to any of the URLs being returned so that even though the content was crawled and indexed with the URLs starting with http://ourintranet, if a user comes in on the http://extranet.mycompany.com URL and performs a search, then all search results will also use the http://extranet.mycompany.com access mapping.

Now to the issue with the ListUrl property being returned by search. This property simply misses the whole alternate access mapping transformation when the search results are returned and the value is read straight from the search index. Therefore the ListUrl property is fixed with the URL host that the search crawler is configured with. This means that when a user comes in on http://extranet.mycompany.com and performs a search, the ListUrl property will give back a result starting with http://ourintranet. Obviously this is not good and your users may not even have access to the content via the different access mapping.

Here’s an environment demonstrating the problem.

The initial site collection is created on http://vs-server38:83

01-sharepoint-aam-listurl-search-results-cameron-dwyer-site-collections

 

The site collection is then extended (which creates the alternate access mapping) http://vs-server38:84

02-sharepoint-aam-listurl-search-results-cameron-dwyer-extended-to-new-port

 

Through a browser we can now access the same site on http://vs-server38:83

03-sharepoint-aam-listurl-search-results-cameron-dwyer-port-83

 

or on http://vs-server38:84

04-sharepoint-aam-listurl-search-results-cameron-dwyer-port-84

 

The search content source is configured to crawl the content based on the default http://vs-server38:83 URL.

05-sharepoint-aam-listurl-search-results-cameron-dwyer-search-content-source-for-crawl

The screenshot below shows the results of performing a search query (via PowerShell) on the URL http://vs-server38:83. As you can see all URLs returned begin with http://vs-server38:83

06-sharepoint-aam-listurl-search-results-cameron-dwyer-search-results-on-port-83

 

This screenshot performs exactly the same search query only it uses the alternate access mapping of http://vs-server38:84. This time the issue is evident. The Path, OriginalPath and SiteName properties all return URLs that have been mapped to the alternate access URL I used. Note the ListUrl property still returns the http://vs-server38:83 based URL.

07-sharepoint-aam-listurl-search-results-cameron-dwyer-search-results-on-port-84

 

Delving further, each managed search property has a property called UseAAMMapping that seems to be the flag that tells SharePoint that the property contains a URL and need to apply alternate access mapping transformation when results are returned. Looking at the UseAAMMapping property through PowerShell we can see that the ListUrl property does not have this flag set while the other URL based properties (that work correctly) do have this flag set.

08-sharepoint-aam-listurl-search-results-cameron-dwyer-listurl-useaammapping-false

Running Fiddler with OnePlaceMail – Fixing “The requested site does not appear to have claims enabled or the Login Url has not been set” message

Here’s a workaround to get Fiddler working with OnePlaceMail and SharePoint 2013 where you normally get the following error message in OnePlaceMail as soon as Fiddler is enabled and capturing traffic:

“The requested site does not appear to have claims enabled or the Login Url has not been set”

clip_image002

I went investigating why introducing Fiddler breaks OnePlaceMail and was able to track the problem down to a single call to the native SharePoint 2013 People web service and in particular the IsClaimsMode method of the People web service. Under the default SharePoint 2013 install (Claims mode with integrated Windows NTLM or Kerberos Authentication) this web method return False without Fiddler and True with Fiddler running.

Using Fiddlers AutoResponder feature we can set up a rule to listen for calls to the IsClaimsMode method of the People web service and return a fixed response from a local file instead of getting it from the SharePoint server.

The particular Fiddler AutoResponder rule matching I used requires one of the later versions of Fiddler, here’s the version I was using: v4.4.9.2

clip_image004

First you need to get the following “response” file onto your computer so Fiddler can use it to respond to any calls made to the IsClaimsMode web service. Here’s the contents of the response file:


<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="<a href="http://schemas.xmlsoap.org/soap/envelope/">http://schemas.xmlsoap.org/soap/envelope/</a>" xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>" xmlns:xsd="<a href="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</a>">
   <soap:Body>
      <IsClaimsModeResponse xmlns="<a href="http://schemas.microsoft.com/sharepoint/soap/">http://schemas.microsoft.com/sharepoint/soap/</a>">
         <IsClaimsModeResult>false</IsClaimsModeResult>
      </IsClaimsModeResponse>
   </soap:Body>
</soap:Envelope>

It’s pretty simple, the web service really only returns a value of true or false. The condition the problem occurs is when the real web service gives back a true when it should be false.

In my example I’ve placed the file on the following path:

C:\Users\cdwyer\Documents\Fiddler2\Captures\sp2013people.asmx.xml

Now start up Fiddler and select the AutoResponder tab and check the following options:

- Enable automatic responses

- Unmatched requests passthrough

clip_image006

Click Add Rule and put the following match rule in (this will identify any web service calls to the IsClaimsMode method:

Header:SOAPAction=”http://schemas.microsoft.com/sharepoint/soap/IsClaimsMode

clip_image008

Now in the action to execute line choose Find a file… from the drop down

clip_image010

Select the AutoResponder file we created in the earlier step

clip_image012

The AutoResponder tab should now look like this

clip_image014

Using OnePlaceMail with Fiddler running should now work without raising the error.

Is the SharePoint brand going away?

The big push from Microsoft over the last few years has been towards the cloud, and in the SharePoint area this means Microsoft wants you on Office 365 instead of on-premises SharePoint servers.

None of this should shock you, Microsoft has been yelling it loud and clear for some time now, and the message came through loud and clear at the SharePoint Conference in Las Vegas this year (my key takeaways from the SPC14). It has now been announced that was the last SharePoint conference and starting in 2015 a conference combining SharePoint, Lync, Exchange, Project, Office365 will run instead.

Here’s some interesting stats pulled from Google trends.

trends-office365-vs-sharepoint

Office 365 (blue) vs SharePoint (red) – Shows interest in SharePoint slowly declining while interest in Office 365 has been rapidly increasing to roughly double that of SharePoint.

Microsoft’s Office 365 offering is compelling now they are starting to realize the benefits from combining multiple services into a single integrated offering. I don’t necessarily think Microsoft is trying to kill SharePoint off, it’s just drifting towards the background a bit in the noise of Office 365. When you look at Office 365, there are quite a few products that were thrown into the mix… SharePoint, Exchange, Yammer, Office Online, OneDrive, FAST. Trying to combine and integrate these products and leverage their combined power, Microsoft is heading towards talking about the tangible objects and features rather than the technology.. what do I mean by that? We start hearing terms like Conversations which may be a mixed thread of Email/Lync/Yammer all shown together, we start to talk of Documents whether they be stored in SharePoint and viewed with Office Online Apps, Office Desktop apps or accessed via OneDrive. It seems the technologies themselves are losing the focus and the rather the functionality they provide is coming to the fore (and I think this is where the rub comes for those hanging on to SharePoint on premises), this really awesome functionality is not provided by one product on it’s own, but rather when they are integrated together and the only way to get the highest level of integration and deliver this value is in Microsoft’s Office 365 cloud. So is SharePoint going away? I think it’s just becoming part of something bigger, and over time the functionality might just be called Sites or Workspaces or Places or Groups in Office 365 but it will essentially be the SharePoint of today powering the functionality delivered in the Office 365 of tomorrow.

 

trends-office365-vs-google-apps-cameron-dwyer

Office 365 (blue) vs Google Apps (red) – Office 365 is competing with Google for taking business apps to the cloud and looking at Office 365 vs Google Apps or Google Docs these stats show a pretty fierce battle underway.

 

trends-office365-vs-google-docs-cameron-dwyer

Office 365 (blue) vs Google Docs (red) – Office 365 is competing with Google for taking business apps to the cloud and looking at Office 365 vs Google Apps or Google Docs these stats show a pretty fierce battle underway.

Getting Started: The Basics of Using PowerShell with SharePoint

I’m a SharePoint guy, and certainly no PowerShell expert. I know enough PowerShell to get things done in SharePoint from time to time. I can often go months without using PowerShell and talking to colleagues I don’t think I’m alone in the SharePoint community.

So if you are just starting out with using PowerShell to do something with SharePoint, or it’s been a while and you need a refresher on the basics then you’ve come to the right place.

Before we get started I’m writing this article based on SharePoint 2013 running on a Windows 2012 server.

The ground rules

1) Run your PowerShell scripts from the SharePoint server itself

It is possible to run PowerShell against a remote SharePoint server rather than on the server itself, but it requires some setup on the SharePoint server side and let’s face it, it’s not basic. If you need to do it you need to be searching for “Remote PowerShell in SharePoint”.

2) Use Windows PowerShell ISE (not SharePoint Management Shell)

PowerShell needs to be executed/run at a PowerShell Console or PowerShell Window – this window looks like a standard Command Line window and I don’t find it too inviting.

Instead of the SharePoint 2013 Management Shell, I use the Windows PowerShell ISE.

sharepoint-powershell-getting-started-cameron-dwyer-windows-powershell-ise

Why? It’s like comparing Visual Studio with Notepad. The ISE is an environment for developing PowerShell scripts that gives you nice syntax highlighting, debug with breakpoints, intellisense and more. It’s more like a development environment than a command line. I think you’d agree it looks slightly more advanced.

sharepoint-powershell-getting-started-cameron-dwyer-powershell-ise

3) Ensure the SharePoint PowerShell snapin is loaded

When using the “SharePoint 2013 Management Shell” (the ugly black one) it automatically loads a “snapin” which is basically a PowerShell extension that gives you a series of commands for working with SharePoint objects. When you use the Windows PowerShell ISE it has no idea of SharePoint, so you need to load the SharePoint snapin manually. The simplest way to do this is just to add the following code snippet to the start of all your scripts.

if((Get-PSSnapin "Microsoft.SharePoint.PowerShell") -eq $null)
{
      Add-PSSnapin Microsoft.SharePoint.PowerShell
}

 

4) Save a script to file before you try to run it

Windows PowerShell ISE will have trouble running a script if you haven’t saved it to disk yet. PowerShell scripts are saved as files with a .ps1 extension.

 

5) Talk to SharePoint via the SharePoint PowerShell Cmdlets

Here’s a reference of all the SharePoint 2013 PowerShell Cmdlets you can use to work with SharePoint.

 

Your first script

Pre-flight checklist:

  • Start Windows PowerShell ISE
  • Add code snippet for loading the SharePoint snapin
  • Save the script as a .ps1 file

sharepoint-powershell-getting-started-cameron-dwyer-first-script

You can now start cutting and pasting examples from the internet and modifying them to work with your environment. The following 2 lines get a handle on the SharePoint website at the URL http://vs-server12 and then output the ID of the website.

To run the script and see if it work, click the Run button.

sharepoint-powershell-getting-started-cameron-dwyer-run-script

Any output from running your script is shown in the output window below the script editor.

sharepoint-powershell-getting-started-cameron-dwyer-output

You’re on your way, just remember you can only access the SharePoint server on which you are running your scripts. Accessing remote SharePoint servers is possible but you need to do special magic stuff to make that happen Smile

 

If you encounter an error along the lines of:

Get-PSSnapin : No Windows PowerShell snap-ins matching the pattern “Microsoft.SharePoint.PowerShell” were found.

You’ve ignored ground rule 4 and the pre-flight checklist by forgetting to save your script before running it (yes, I still do this too).

 

How to fix issue with opening Visual Studio solution from tfspreview.com by moving it to visualstudio.com

This problem arises if you were using Team Foundation Services (TFS) Online while it was still in preview. You will be accessing TFS on a URL such as: https://mycompany.tfspreview.com A recent change has been made to TFS Online that prevents you opening solutions using this URL. When you try to open an existing solution (that you have already synced down to your development machine ) you will see the following error message in Visual Studio:

image

Attempting to “Go Online” with the solution, or disconnect from TFS and reconnect using the same tfspreview.com address will result in a security credentials prompt that accepts your credentials but just sits there blank. BTW trying to login to the tfspreview.com URL in IE also results in this blank page behavior, in Chrome it gives a slightly better redirect error.

image

What Microsoft want you to use instead is the visualstudio.com address instead: https://mycompany.visualstudio.com.

This is simple if you just want to access TFS in a browser. Simply use the new address, but how do you get Visual Studio to start using the new URL to connect for a solution you already have on your dev machine?

Here’s the process that’s worked for me across Visual Studio 2012 and 2010.

Remove the existing TFS Connection from The Team Explorer

image

 

Now Add a TFS Connection using the visualstudio.com URL

image

 

Open the TFS Source Control Explorer now you are connected using the new visualstudio.com address

image

 

Select the solution folder for the solution you have synced to the local workspace on your development machine. Right click the solution folder and select the Get Specific Version… option from the context menu.

image

 

Ensure you check the option to “Overwrite all files even if the local version matches the specified version”. This will effectively pull all files for the solution from TFS again even if there has been no change made to the files. This has the side effect of fixing the binding of the files so that after the sync the files will now be bound to visualstudio.com instead of tfspreview.com.

image

 

Once the sync has completed you should see the following message:

image

 

Click Yes, and you will get a dialog letting you know of any offline changes.

image

 

That should be job done. Your Solution Explorer should now show the TFS icons indicating the source control state of all the files and you’ve now left the tfspreview.com URL behind.

Other links referencing this issue:

http://social.msdn.microsoft.com/Forums/vstudio/en-US/4c887b08-60fe-40fb-8e25-81ab4c267003/cant-connect-to-tfspreview-in-vs11-but-can-via-ie?forum=TFService

 

How to bulk upload/copy a folder structure and files to SharePoint

So you’ve got a bunch of files nicely arranged in a folder structure sitting on your computer or a network drive that you want to copy up to a SharePoint library and preserve the directory structure. On the surface this is a daunting task as you can’t just give SharePoint your folder structure and tell it to do the work for you, so what are your options.

 

Option 1: Manually via SharePoint IU

Recreate the folder structure in SharePoint and upload the files via SharePoint UI in batches doing a multiple file upload to one destination folder at a time. Not much fun for anyone, but it can be done.

 

Option 2: Commercial Tool

Try a 3rd party tool. Yes they will probably cost you but will get the job done and probably with a few extra bell’s and whistles like applying metadata to SharePoint columns during the process. Some of the key companies to take a look at would be:

 

Option 3: Open Source Tools

There are some open source projects going around that claim to handle these types of bulk uploads, here’s a couple that look interesting:

http://spbulkdocumentimport.codeplex.com/

http://spfileupload.codeplex.com/

 

Option 4: Script it Yourself

PowerShell is an awesome way to get things done quickly in SharePoint, I’ve written these scripts in the past that show you how to create folders and how to upload documents to SharePoint. With a bit of extension and effort you could roll your own scripted solution.

https://camerondwyer.wordpress.com/2013/05/27/how-to-import-upload-an-entire-folder-of-files-to-sharepoint-using-powershell/

https://camerondwyer.wordpress.com/2013/11/06/sharepoint-powershell-how-to-create-sharepoint-library-folders-for-loadperformance-testing/

 

Option 5: Explorer View

The old ‘Open Library in Explorer View’ option in SharePoint may get you out of trouble if the directory structure and number of files is fairly small. Simply use the Explorer View to open the SharePoint library up in a Windows Explorer window and then copy/paste or drag/drop into the Window and the magic will start to happen

 

Option 6: OneDrive for Business

Now this is my preferred option for getting the job done, and the reason for writing this blog post! To achieve this one, browse to your library in SharePoint and click on the sync button to have the SharePoint library sync’d via OneDrive to your local machine.

bulk-upload-folder-structure-sharepoint-cameron-dwyer-onedrive-sync-button

After the sync has completed the SharePoint library (and it’s content including any folder structure) is now represented as a folder structure that you can easily get to through Windows Explorer.

bulk-upload-folder-structure-sharepoint-cameron-dwyer-onedrive-local-library

Now it’s just a matter of copy/paste or drag/drop your local folder structure (that you want to copy to SharePoint) into this folder in Windows Explorer. Here is my folder structure I want to copy up to SharePoint.

bulk-upload-folder-structure-sharepoint-cameron-dwyer-folders-to-upload

So I can just copy the “My Folder Structure” folder and paste it into the SharePoint sync library location. This is super quick because it’s just copying between 2 locations on your local hard drive.

bulk-upload-folder-structure-sharepoint-cameron-dwyer-onedrive-sync

Now the real goodness happens. OneDrive will sync the entire folder structure including any content files up to SharePoint in the background. You will notice that the folders and files you have just pasted have a tiny icon in the left corner. This will display a green tick when the item has been created in SharePoint. This is awesome, your computer is still free to use, there’s no lockup. If you need to shutdown before the sync is finished, it will just pick up from where it left off. OneDrive’s mission in life is to keep your local folder in sync with the SharePoint library, and it will work tirelessly in the background to do this.

Another powerful advantage this method has over many of the other options I provided earlier is that it will work with Office 365 which you just can’t reach some of those other methods.

Now my disclaimer before I get people throwing virtual rotten fruit at me. I’m not suggesting you use this method to move an entire network drive to SharePoint. Yes, I advocate you should take the opportunity to clean up the data on your network drives and not just move the problem to SharePoint. I also believe in the use of metadata to classify content rather than using folders. Having said that, there are valid instances when you do need to perform an upload of many files and preserve the folder structure in SharePoint and I think the OneDrive approach is a pretty cool tool to add to your arsenal.

SharePoint PowerShell How To: Create SharePoint List Items (in Root and in Folders) for Load/Performance Testing

SharePoint PowerShell How To Series – Foreword

I often find myself scratching around the local drive of my development machines for remnants of PowerShell scripts to generate list & libraries in SharePoint with all sorts of different folder hierarchies to test the performance of code I’m working on to ensure it scales well once the folder & item counts start getting up to high numbers. So rather than keep scratching I’m going to start posting my scripts as I create and use them so I can find/reuse them later on and someone else might find them useful as well. I’m sure they won’t work under all scenarios and situations (and they are not designed to). They are just quick scripts that serve a specific purpose to me at the time and you may be able to tweak to fit your needs.

Create list items in the root of a custom SharePoint list

Script description: Creates 10,000 list items in the root folder of the “OnePlace License R7” list of the site located at the URL “vs-server38”.

#Add SharePoint PowerShell Snapin which adds SharePoint specific cmdlets
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue

# Script settings
$webUrl = "http://vs-server38"
$listName = "OnePlace Licenses R7"
$numberItemsToCreate = 10000
$itemNamePrefix = "License "

# Open web and library
$web = Get-SPWeb $webUrl
$list = $web.Lists[$listName]

# Create desired number of items in subfolder
for($i=1; $i -le $numberItemsToCreate; $i++)
{
$newItemSuffix = $i.ToString("00000")
$newItem = $list.AddItem()
$newItem["Title"] = "$itemNamePrefix$newItemSuffix"
$newItem.Update()
write-host "Item created: $itemNamePrefix$newItemSuffix"
}

#Dispose web
$web.Dispose()

Create list items in a folder of a custom SharePoint list

Script description: Creates 10,000 list items in the “OnePlaceDocs” folder of the “OnePlace License R7” list of the site located at the URL “vs-server38”.

Note: this assumes you have already created a folder called “OnePlaceDocs”in the list.

#Add SharePoint PowerShell Snapin which adds SharePoint specific cmdlets
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue

# Script settings
$webUrl = "http://vs-server38"
$listName = "OnePlace Licenses R7"
$subFolderName = "OnePlaceDocs"
$numberItemsToCreate = 10000
$itemNamePrefix = "License "

# Open web and library
$web = Get-SPWeb $webUrl
$list = $web.Lists[$listName]

# Get handle on the subfolder
$subFolder = $list.RootFolder.SubFolders.Item($subFolderName);

# Create desired number of items in subfolder
for($i=1; $i -le $numberItemsToCreate; $i++)
{
$newItemSuffix = $i.ToString("00000")
$newItem = $list.AddItem($subFolder.ServerRelativeUrl, [Microsoft.SharePoint.SPFileSystemObjectType]::File, $null)
$newItem["Title"] = "$itemNamePrefix$newItemSuffix"
$newItem.Update()
write-host "Item created: $itemNamePrefix$newItemSuffix"
}

#Dispose web
$web.Dispose()

Others articles in this series:

What’s the difference between a UX designer and a UI designer?

I love this infographic, quickly sums up the differences (and similarities) between a UX designer and a UI designer.

[Click the image to see full size]

UX-designer-vs-UI-designer-difference-and-similarites-Infographic

Follow

Get every new post delivered to your Inbox.

Join 92 other followers

%d bloggers like this: