Tag Archives: SharePoint

Chocolately at Work and Home

If you haven’t seen http://chocolatey.org/ then go check it out!    “Chocolately is a Machine Package Manager, somewhat like apt-get, but built with Windows in mind”

This simple yet incredible utility helps us download and install applications.    Need Chrome?   Great!   Type “choco install GoogleChrome”, kick your feet up, and wait for Chrome to appear on the desktop.  Just that easy.  shades_smile

 

 

Below are my favorite Chocolatey shopping lists for 3 different scenarios:

  1. Home – Personal or family use.  browsers, plugins, security, support, and utilities.
  2. Work (Developer Desktop) – Code creation and management, debug, trace, inspect.  Overlaps some with Home.
  3. Work (SharePoint Server) – Administrator tools, troubleshoot, logs, utilities, and remote management.

 

Home

cinst 7zip
cinst 1password
cinst adobeair
cinst adobereader
cinst anyvideoconverter
cinst audacity
cinst autohotkey.portable
cinst balsamiqmockups
cinst calibre
cinst ccleaner
cinst crashplan
cinst defraggler
cinst dropbox
cinst evernote
cinst firefox
cinst flashplayerplugin
cinst flashplayeractivex
cinst gimp
cinst googlechrome
cinst googledrive
cinst googleearth
cinst handbrake
cinst imagemagick
cinst infrarecorder
cinst itunes
cinst javaruntime
cinst jing
cinst jre8 8.0.65 
cinst lastpass
cinst keepass
cinst malwarebytes
cinst minecraft
cinst nestopia
cinst notepadplusplus
cinst notepadreplacer
cinst office365homepremium
cinst paint.net
cinst pdfill
cinst pdftk
cinst processhacker
cinst produkey
cinst quicktime
cinst recuva
cinst sandboxie
cinst skype
cinst snagit
cinst speccy
cinst spotify
cinst teamviewer
cinst ultraiso
cinst vlc
cinst wifi-manager
cinst winrar
cinst wizmouse
cinst zoomit

 

Work – Developer Desktop

cinst 7zip
cinst altdrag
cinst attributechanger
cinst brackets
cinst chocolateypackageupdater
cinst cloc
cinst conemu
cinst crystaldiskinfo
cinst crystaldiskmark
cinst googlechrome
cinst dotpeek
cinst expresso
cinst fiddler
cinst filezilla
cinst firefox
cinst hosts.editor
cinst keepass
cinst notepadplusplus
cinst notepadreplacer
cinst git
cinst git.commandline
cinst github
cinst icofx
cinst ilspy
cinst kindle
cinst lessmsi
cinst linqpad
cinst lockhunter
cinst markdownpad2
cinst meld
cinst mousewithoutborders
cinst npm
cinst nodejs
cinst nuget.commandline
cinst patheditor
cinst p4merge
cinst puretext
cinst python2
cinst rdcman
cinst resharper
cinst ruby
cinst searchquerytool
cinst sharepointdesigner2013x86
cinst slack
cinst sqlserver2014express
cinst tortoisesvn
cinst typescript
cinst ulsviewer
cinst usbview
cinst universal-usb-installer
cinst virtualbox
cinst visualstudio2013ultimate
cinst windowslivewriter
cinst winmerge
cinst winrar
cinst wireshark
cinst wudt
cinst xmlnotepad
cinst yeoman
cinst zoomit

 

Work – SharePoint Server

cinst adexplorer
cinst bulkrenameutility
cinst camlviewer
cinst ccleaner
cinst defraggler
cinst hosts.editor
cinst logparser
cinst logparser.lizardgui
cinst logexpert
cinst msicuu2
cinst notepadplusplus
cinst notepadreplacer
cinst patheditor
cinst powergui
cinst recuva
cinst regshot
cinst rdcman
cinst rktools.2003
cinst softerraldapbrowser
cinst speccy
cinst switcheroo
cinst sysinternals
cinst treesizefree
cinst vcredist2010
cinst urlrewrite
cinst webdeploy
cinst webpi
cinst webpicmd
cinst zoomit

Rename MySite “Blog” for findability

SharePoint names the blog created in a personal site “Blog.”  At scale this is confusing because everyone’s blog has exactly the same title (“Blog”).

The below PowerShell will rename to “{FirstName LastName} – Blog” for a more user friendly experience across search results, follow site recommendations, and site directory.

Cheers!  shades_smile

#get all personal site blogs
$webs = Get-SPSite -Limit All |? {$_.RootWeb.WebTemplate -eq "SPSPERS"} | Get-SPWeb -Filter {$_.Template -eq "BLOG"} -Limit All
foreach ($w in $webs) {
	#progress display
	$w.Url
	
	#filter
	if ($w.Title -eq "Blog") {
		#AD lookup
		$splits = $w.Site.Url.Split("/")
		$login = $splits[$splits.length - 1]
		$user = Get-ADUser $login
		$name = $user.Name
		$title = "Blog - $name"
		
		#save
		$w.title = $title
		$w.Update()
		$w.Title
	}
}

Office 365 – Monitor site collection storage (PS1 daily email)

I wrote the below PowerShell script to gather site collection storage data for any Office 365 tenant.  This PS1 could be scheduled daily for a quick email to keep an eye on sites approaching storage limits.

Hope this helps!  shades_smile

 

5-18-2015 8-47-11 PM

# Plugin
Import-Module Microsoft.Online.SharePoint.PowerShell -ErrorAction SilentlyContinue
# Config -- get URL from "Tenant Admin" page in Office 365
$url	= "https://company-admin.sharepoint.com"
$user	= "admin@company.com"
$smtp	= "mailrelay"
# Connect
Connect-SPOService -url $url -credential $user
# Gather data
$sites = Get-SPOSite -Detailed
$coll = @()
foreach ($s in $sites) {
	$curr = $s.StorageUsageCurrent
	$quota = $s.StorageQuota
	if ($quota -eq 0) {
		$prct = [math]::Round($curr, 2) * 100
	} else {
		$prct = [math]::Round($curr/$quota, 2) * 100
	}
	$surl = $s.Url
	$coll += New-Object -TypeName PSObject -Prop (@{'curr'=$curr;'quota'=$quota;'prct'=$prct;'surl'=$surl})
}
$coll = $coll | sort prct -Desc
	
# Format HTML
$html = ""
foreach ($c in $coll) {
	$row = "" -f $c.surl, $c.curr, $c.quota, $c.prct
	$html += $row
}
$html += "
URL Current (MB) Quota (MB) Percent
{0} {1} {2} {3} %
 
" # Send email Send-MailMessage -To $user -From $user -Subject "Office 365 Storage" -Body $html -BodyAsHtml -SmtpServer $smtp

IISFlush.ps1

While troubleshooting an error with Excel Web Access I found recycle wasn’t sufficient and IISRESET was needed.   However, this raised questions about daily scheduled IIS recycle and if that would be enough to give a stable IIS footprint each business day.   I decided to err on the side of caution and schedule a full IISRESET along with code to ensure all sites and pools started up again OK.   PowerShell below.  

 

Also, I would recommend installing SPBestWarmUp (http://spbestwarmup.codeplex.com)  by running “spbestwarmup.ps1 –install”    This creates a Scheduled Task repeating every 15 minutes to simulate user traffic and keep those IIS pools responsive for end users.   No more wait on first visit.   It even warms up Central Admin to help out SharePoint admins.  

 

Enjoy!  shades_smile

 

# Reset IIS and verify 100% started.  Twice to be sure  =)
Import-Module WebAdministration -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Out-Null
function IISGo {
	NET START W3SVC
	Get-ChildItem IIS:\AppPools |% {Start-WebAppPool $_.Name}
	Get-WebSite | Start-WebSite
}
IISRESET
Sleep 5
IISGo
Sleep 5
IISGo

Apply standard Audit Events to all sites

Standardized settings are essential for organizational compliance needs.  All sites should be treated the same with minimum settings enforced.  The below PowerShell script will enable Audit Event tracking and apply the same setting for all sites in the farm.   Enjoy!    shades_smile

 

 

 

 

#===============================================
#  Set all Site Collection Audit Flags
#===============================================
#  Filename:	Set_SiteCollectionAuditFlags.ps1
#  Purpose:		Apply standard Audit Events for all sites in the farm
#  Author:		spjeff@spjeff.com
#  Modified:	03-09-2015
#===============================================
Write-Host "Getting sites ... " -NoNewLine
$sites = Get-SPSite -Limit ALL
Write-Host "[OK]"
$start = Get-Date
$i = 0
$changes = 0
# All without View events AuditMask = 16379
# View events =+4, so AuditMask+Read = 16383
$auditMask = [Microsoft.SharePoint.SPAuditMaskType]::CheckOut `
-bxor [Microsoft.SharePoint.SPAuditMaskType]::CheckIn `
-bxor [Microsoft.SharePoint.SPAuditMaskType]::Delete `
-bxor [Microsoft.SharePoint.SPAuditMaskType]::Update `
-bxor [Microsoft.SharePoint.SPAuditMaskType]::ProfileChange `
-bxor [Microsoft.SharePoint.SPAuditMaskType]::ChildDelete `
-bxor [Microsoft.SharePoint.SPAuditMaskType]::SchemaChange `
-bxor [Microsoft.SharePoint.SPAuditMaskType]::SecurityChange `
-bxor [Microsoft.SharePoint.SPAuditMaskType]::Undelete `
-bxor [Microsoft.SharePoint.SPAuditMaskType]::Workflow `
-bxor [Microsoft.SharePoint.SPAuditMaskType]::Copy `
-bxor [Microsoft.SharePoint.SPAuditMaskType]::Move `
-bxor [Microsoft.SharePoint.SPAuditMaskType]::Search
# Open all site collections, loop for each site, if AuditMask is not our standard of 16379 or 16383 
# then set AuditMask to standard value of 16379
foreach ($site in $sites) {
	# Progress Tracking
	$i++
	$prct = [Math]::Round((($i / $sites.Count) * 100.0), 2)
	$elapsed = (Get-Date) - $start
	$remain = ($elapsed.TotalSeconds) / ($prct / 100.0)
	$eta = (Get-Date).AddSeconds($remain)
	
    # Operation
 	if ( ($site.RootWeb.Audit.AuditFlags -ne 16379) `
	-and ($site.RootWeb.Audit.AuditFlags -ne 16383) )
	{
		$site.RootWeb.Audit.AuditFlags = $auditMask
		$site.RootWeb.Audit.Update()
		$changes++
	}
	
	# Display
	Write-Progress -Activity "Site $Url ETA $eta" -Status "$prct" -PercentComplete $prct
}
Write-Host "Total Changes: $changes"

InfoPath tip – detect Security Group with List Item permissions

Yes, everyone says InfoPath is dead … but we’re all still supporting it for a while so I wanted to share one of my favorite tips.  Forms often need role based security at the field level.  Table below with example security matrix.

How can InfoPath detect that?   Don’t some people query SOAP ASMX?   Or even a custom WSP with a custom ASMX?   There is a simpler way with List Item permission.  

image

  1. Create a new Custom List named “SecurityLevel” with only the default “Title” column.  
  2. Go create the needed SharePoint Groups under Site Permissions.  
  3. Back in “SecurityLevel” add one new item for each SharePoint Group with an identical name.   Hover that item, pull down the menu, and set Item Level Permissions for that group ONLY to have “Read” on that item only.  
  4. With InfoPath Designer edit the XSN Form Template and create a new Data Connection to the list “SecurityLevel” with auto refresh.  
  5. Under Form Load create a rule … if count(SecurityLevel [“Analyst”]) > 0 then set field “SecurityLevel=Analyst”.   
  6. With that in place you are ready to apply formatting rules anywhere needed that use “SecurityLevel” to determine hide/show or read/write.

 

Voila!

Now when a user open the InfoPath form, the data connection “SecurityLevel” will only show the items they have access to (which is the same as the SharePoint Group membership!).    Works on MOSS 2007, SharePoint 2010, SharePoint 2013, and Office 365.

Hope this helps.  Please leave a comment if it did.  shades_smile

 

DOWNLOAD  InfoPath Form – SecurityLevel.xsn >>

 

 

image

image

image

image

image

 

image

image

image

Estimated Arrival Time (ETA) for PowerShell

Ever had a script that takes a long time to run?    Would it be nice to see an estimated time for completion?   Well, the code below is for you.   shades_smile

 

Percentage complete is an easy calculation for any loop operation.  Deriving time from that requires us to hold ($start) with the time our loop began.  From there we can multiply out and calculate total seconds.   When total seconds remaining is added to the current time .. then … you have ETA.  Example below.

 

image

 

# Data Source
$sites = Get-SPSite -Limit All
# Initialize Tracking
$start = Get-Date
$i = 0
$total = $sites.Count
# Loop
foreach ($site in $sites) {
	# Progress Tracking
	$i++
	$prct = [Math]::Round((($i / $total) * 100.0), 2)
	$elapsed = (Get-Date) - $start
	$totalTime = ($elapsed.TotalSeconds) / ($prct / 100.0)
	$remain = $totalTime - $elapsed.TotalSeconds
	$eta = (Get-Date).AddSeconds($remain)
	
	# Display
	$file = $site.Url.Split('/')[4]
	Write-Progress -Activity "Backup $file ETA $eta" -Status "$prct" -PercentComplete $prct
	
	# Operation
	Backup-SPSite $site.Url -Path "D:\TEMP\$file.site" -WhatIf
}

Visio 2013 – new shapes and color scheme

Today I opened Visio to draw a simple network topology.  The default shapes are different from Office 2010 and have taken more of a Windows 8 (“Modern UI”) look.  Below are some an examples and stencil downloads for drawing the newer style of Microsoft diagrams.

 

Downloads

 

image

Two Ways to Check SQL Aliases for SharePoint

Today I was working on a server and wanted to confirm the SQL alias settings were correct.   There are two ways to do this and I wanted to compare both techniques.

 

1 – CLICONFG  (Bad Way)

The old stand-by.   Trusty EXE file names that just work.   Win + R + CLICONFG.EXE is a favorite for keyboard shortcut key gurus. 

image

 

To see 32-bit settings run “%SystemDrive%\Windows\sysWOW64\cliconfg.exe”   Yes, not as easy to type.  

But wait a minute.  Both windows look exactly the same!   Whaaaaat??    That’s no good.  In a world of 32-bit only this worked fine, but things change and our tools should too.

 

image

 

2 – SSMS (Good Way)

I install SQL Server Management Studio (SSMS) on all of my SharePoint web front ends (WFE) for support and troubleshooting.  It’s a great way to confirm the WFE can “see” SQL and connect successfully.   If your organization has a separate DBA team which manages SQL, this is even more helpful because you can look at the databases and run queries even without RDP access to the SQL machines.  Checking storage used, last backup time, and permissions are all helpful read-only tasks we can safely do with SSMS.

With SSMS installed, you get a Start Menu icon for “SQL Server Configuration Manager.”  Launch that and you’ll be able to view aliases for both 32-bit and 64-bit drivers.  You can also run the MSC directly from PowerShell, the command line, or Start > Run.

SQL 2008 R2SQL 2012
SQLServerManager10.mscSQLServerManager11.msc

Both are in one place!  Clearly labeled and easy to read!   Now that’s much better in a modern 32/64 world.

 

image

image

image

So there you have it.  Two different ways to look at your SQL alias settings. 

As much as I used CLICONFG.EXE over the years, today I use the GUI because it’s a helpful reminder to look at both 32 and 64-bit settings all at once.   Consistency = fewer issues = happy admins.  Smile

Return to Top ▲Return to Top ▲