Powershell Archive

Errors Running New site collection

Posted May 20, 2014 By Kevin Bennett

I ran into an error running a new site collection on our new Server 2012 SharePoint 2013 Web Farm.

Here is the link to the error and ULS logs: Error in Sharepoint 2013

Although I have yet to figure out what is causing the error I was able to narrow it down to relating to Claims Based Authentication.

I worked around this by removing the Web Application that was using Claims Based and created a Windows Authenticated Web Application. You can not do this via the GUI and need to run a powershell command to complete.

The command I ran was:

New-SPWebApplication -Name -ApplicationPool -AuthenticationMethod -ApplicationPoolAccount -Port -URL

I will update if I ever figure out why Claims is not working. A few things I need to look into are Ports and Permissions, since these are managed by different departments than mine I suspect that used the least privilege/access which might be causing my issues.

Be the first to comment

How I installed SharePoint 2013 on Server 2012 R2

Posted February 28, 2014 By Kevin Bennett

Currently there is Service Pack 1 out for SharePoint 2013 and it can be found here http://www.microsoft.com/en-us/download/details.aspx?id=42008

But as of the writing you still needed to install SharePoint 2013 onto Server 2012 R2 before applying the service pack, which is not support by Microsoft.

Attempting to do so would generate errors related to App Server Role not installing correctly. Below I will show step you through the steps I completed to successfully install SharePoint 2013 onto Server 2012 R2.

In my scenario I wasn’t able to access the internet from the Servers I was installing SharePoint on so I will cover this as an offline install.

1. To install the Roles and Features that are required by SharePoint 2013 on Windows Server 2012 in an offline environment, you must have access to the Windows Server 2012 installation media. You can then run the same Windows PowerShell commands that you used in Method 2, but you must use the -source parameter to specify the location of the required files on the installation media.

For example, assume that you mounted the Windows Server 2012 installation media (ISO) to drive D of the server. Then, the path to provide for the -source parameter is as follows:
D:\sources\sxs
Note Be aware that you can also copy the files locally or specify a UNC path where the installation files are stored.
Open an elevated Windows PowerShell prompt on the SharePoint server (that is, Run as Administrator), and execute the following commands:

Import-Module ServerManager
Add-WindowsFeature NET-WCF-HTTP-Activation45,NET-WCF-TCP-Activation45,NET-WCF-Pipe-Activation45
Add-WindowsFeature Net-Framework-Features,Web-Server,Web-WebServer,Web-Common-Http,Web-Static-Content,Web-Default-Doc,Web-Dir-Browsing,Web-Http-Errors,Web-App-Dev,Web-Asp-Net,Web-Net-Ext,Web-ISAPI-Ext,Web-ISAPI-Filter,Web-Health,Web-Http-Logging,Web-Log-Libraries,Web-Request-Monitor,Web-Http-Tracing,Web-Security,Web-Basic-Auth,Web-Windows-Auth,Web-Filtering,Web-Digest-Auth,Web-Performance,Web-Stat-Compression,Web-Dyn-Compression,Web-Mgmt-Tools,Web-Mgmt-Console,Web-Mgmt-Compat,Web-Metabase,Application-Server,AS-Web-Support,AS-TCP-Port-Sharing,AS-WAS-Support, AS-HTTP-Activation,AS-TCP-Activation,AS-Named-Pipes,AS-Net-Framework,WAS,WAS-Process-Model,WAS-NET-Environment,WAS-Config-APIs,Web-Lgcy-Scripting,Windows-Identity-Foundation,Server-Media-Foundation,Xps-Viewer -Source G:\Sources\sxs
2. Your server may require a restart after you run this Windows PowerShell code.
3. Install the other prerequisites that are required by SharePoint 2013. except App Fabric Setup (See #4) – Found a lot of direct links to download Pre’s here http://social.technet.microsoft.com/wiki/contents/articles/14582.sharepoint-2013-install-prerequisites-offline-or-manually-on-windows-server-2012-a-comprehensive-guide.aspx#Downloading_the_SharePoint_2013_Prerequisite_files_for_Offline_Installation
4. as stated above you will need to run the following in powershell to install the App Fabric software because it requires special settings. In Powershell run .\WindowsServerAppFabricSetup_x64.exe /i CacheClient”,”CachingService”,”CacheAdmin /gac
5. Run App Fab Patch
6. Reboot
7. Run SP 13 Setup
8. Run SP12 SP1

And that will do it.

Good luck.

Be the first to comment

This is a simple little script that I added on to a previous script to get Computer Bitlocker Report and Post the totals to Sharepoint 2010 List


# Check if the Sharepoint Snapin is loaded already, and load if not
if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{
Add-PSSnapin Microsoft.SharePoint.PowerShell
}

$reportcsv = Import-CSV q:\.csv

$totalTrue = $reportcsv | Where-Object {$_. -eq "TRUE"} | Measure-Object HasBitlockerRecoveryKey -line
$totalFalse = $reportcsv | Where-Object {$_. -eq "FALSE"} | Measure-Object HasBitlockerRecoveryKey -line

#Setting our variables, Site name, List name, file to import and Caml
$spWeb = Get-SPWeb -Identity "https://"
$Summarylist = $spWeb.Lists[""]

#adds Report to SharePoint List
$item = $list.Items.Add();
$item["True"] = $totalTrue.lines;
$item["False"] = $totalFalse.lines;
$item.Update();

Of course you should replace the that I put in above with your info, but you get the idea.

Kevin

Be the first to comment

Getting Document Information on a SharePoint Site

Posted November 6, 2012 By Kevin Bennett

When I started at this new position they were going through a conversion from SharePoint 2007 to 2010 on the Intranet and Extranet. Actually the day before I started they attempted to the conversion and failed, so as soon as I finished my “in processing” I was pulled out of classes and put to work.

One of the first major projects (after getting the sites back up and running) was to perform a document clean up. As many company’s without a web governance standard knows after several years of uploading documents they didn’t have a handle on what was actually on the site. In order to actually see what was on the site I found/modified the following script (if I got it from you please comment if you find this so I can give credit where it is due).


function Get-DocInventory() {
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local
foreach ($spService in $farm.Services) {
if (!($spService -is [Microsoft.SharePoint.Administration.SPWebService])) {
continue;
}
foreach ($webApp in $spService.WebApplications) {
if ($webApp -is [Microsoft.SharePoint.Administration.SPAdministrationWebApplication]) { continue }

foreach ($site in $webApp.Sites) {
foreach ($web in $site.AllWebs) {
foreach ($list in $web.Lists) {
if ($list.BaseType -ne "DocumentLibrary") {
continue
}
foreach ($item in $list.Items) {
$data = @{
"Web Application" = $webApp.ToString()
"Site" = $site.Url
"Web" = $web.Url
"list" = $list.Title
"Item ID" = $item.ID
"Item URL" = $item.Url
"Item Title" = $item.Title
"Item Created" = $item["Created"]
"Item Modified" = $item["Modified"]
"File Size" = $item.File.Length/1KB
}
New-Object PSObject -Property $data
}
}
$web.Dispose();
}
$site.Dispose()
}
}
}
}
Get-DocInventory | Export-Csv -NoTypeInformation -Path d:\temp\inventory.csv

The script will query the sites on the current farm (I would run this from the WFE Server) and return all the Documents. Note this also returned default.aspx and master pages but I would just filter those out of the spreadsheet.

Using one of my past writeups I would have another PowerShell Script upload to a List on our cleanup site and graph out the information so it looked good using Fusion Charts.

Conclusion of the Project BTW was 289k documents trimmed down to roughly 150k… at least it’s a start!!

Be the first to comment

Update a SharePoint List from a CSV File

Posted September 15, 2012 By Kevin Bennett

So in the last post over on http://SysAdminNightmare.com I created a CSV file for all the domain computers that had a Bitlocker key assigned to it.

Going with the work smarter not harder mantra this post will take that CSV file and update a list on our sharepoint site so I can create a graph.

Note that this must be run from a location where the Sharepoint Snap in is installed, this is usually where Sharepoint is installed so I would save this to a common drive and run from my app server.

UpdateList.ps1

[code]

# Check if the Sharepoint Snapin is loaded already, and load if not
if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{
Add-PSSnapin Microsoft.SharePoint.PowerShell
}

#Setting our variables, Site name, List name, file to import and Caml
$spWeb = Get-SPWeb -Identity “https:///Departments/IT/”
$list = $spWeb.Lists[“Bitlocker”]
$csv = Import-Csv Q:\BitLockerComputerReport.csv
$caml=””

#sets up to remove current items from list
$query=new-object Microsoft.SharePoint.SPQuery
$query.ViewAttributes = “Scope=’Recursive'”
$query.Query=$caml
$items=$list.GetItems($query)

#removes current items from list
$items | % { $list.GetItemById($_.Id).Delete() }

#adds Report to SharePoint List
foreach ($row in $csv)
{
$item = $list.Items.Add();
$item[“Name”] = $row.Name;
$item[“OS”] = $row.OperatingSystem;
$item[“Location”] = $row.Location;
$item[“Bitlocker”] = $row.HasBitlockerRecoveryKey;
$item[“Virtual”] = $row.adminDescription;
$item.Update();
}

#Dispose of SPWeb, to keep things clean and no memory leaks
$spweb.Dispose()

[/code]

Again, you need to change your site name, list name and make sure your list has the correct columns. I would task this to run after the script that creates the CSV file.

Next I have one more post in this series where I take the raw csv file and upload to a sharepoint library incase the bosses want to play around with the numbers (as they always do).

Be the first to comment