• About Ken
  • Ken’s CV

All About SharePoint

~ Liedong(Ken) Zheng, Independent SharePoint Consultant

All About SharePoint

Tag Archives: PowerShell

SharePoint: My Fav Tool Set

09 Wednesday Oct 2013

Posted by ken zheng in Sharepoint

≈ Leave a comment

Tags

PowerShell, Sharepoint, Tool

Planning | Deployment | Administration, Operations and Troubleshooting | Development

Planning

  • MS Downloads WSS3.0/MOSS 2007 Visio stencils for IT Pro posters
  • MS TechNet Technical Diagrams (SharePoint Server 2010)
  • MS TechNet Technical Diagrams (SharePoint Server 2013)
  • HP Sizer for Microsoft Office SharePoint Server 2007: Server and Storage Sizing Tool for SharePoint 2007 running on HP Hardware
  • HP Sizer for Microsoft SharePoint 2010: Server and Storage Sizing Tool for SharePoint 2010 running on HP Hardware
  • Software boundaries and limits for SharePoint 2013
  • Software boundaries and limits for SharePoint 2010
  • Software boundaries and limits for SharePoint 2007
  • Best Practices SharePoint Server 2010
  • Best Practices SharePoint Server 2007
  • SharePoint 2013 Best Practices
  • SharePoint Data Generator project on CodePlex: automatically populates SharePoint lists with realistic test data

Deployment

  • AutoSPInstaller: Fully automated SharePoint 2010 and 2013 installation script
  • PowerGUI: The ultimate free PowerShell IDE
  • Feature Pack for Microsoft SQL Server 2005 SP4: Use Command Line Utilities, PowerShell Extensions and Shared Management Objects to automate SQL databases management jobs with command-line or PowerShell (no native extension!)
  • SQL Server 2008 R2 SP2 Feature Pack: Use Command Line Utilities, PowerShell Extensions and Shared Management Objects to automate SQL databases management jobs with command-line or PowerShell
  • SQL Server 2012 Feature Pack: Use Command Line Utilities, PowerShell Extensions and Shared Management Objects to automate SQL databases management jobs with command-line or PowerShell
  • SQL Server 2012 SP1 Feature Pack: Use Command Line Utilities, PowerShell Extensions and Shared Management Objects to automate SQL databases management jobs with command-line or PowerShell
  • SharePoint Governance and Manageability on CodePlex: Multiple tools for SharePoint 2007 and 2010
  • Gary Lapointe’s Incredible STSADM Extension and PowerShell Cmdlets
  • Forms Based Authentication (FBA) User Management Tool for SharePoint 2010 on CodePlex
  • SharePoint BlobCache Manager project on CodePlex: Provides a Central Admin page to centrally configure Blob Cache settings

Administration, Operations and Troubleshooting

  • SharePoint Manager: Raw SharePoint object viewer and editor for SharePoint 2010 and SharePoint 2013
  • Microsoft Best Practices Analyzer for Windows SharePoint Services 3.0 and the 2007 Microsoft Office System
  • SharePoint Health Analyzer timer jobs in SharePoint 2010
  • SharePoint Health Analyzer timer jobs in SharePoint 2013
  • SharePoint Health Analyzer Rules CodePlex project: brings additional rules to the Health Analyzer.
  • Microsoft SharePoint Administration Toolkit v4.0 for SharePoint 2007 x86 andx64
  • Microsoft SharePoint 2010 Administration Toolkit v2.0
  • Log Parser: The ultimate command-line log analysis utility based on SQL Statements
  • SharePoint Management PowerShell scripts on CodePlex
  • SharePoint (2010) Farm Backup Script on CodePlex
  • SharePoint ULS Log Viewer
  • Idera‘s Free tools: SharePoint admin toolset and SharePoint performance monitor
  • Fiddler: the HTTP inspection proxy and debugging tool, recently aquired byTelerik
  • Microsoft Network Monitor 3.4 together with its Parsers and Experts available from CodePlex
  • PAL project on CodePlex: The ultimate Perflogs parsing and analysis tool
  • SharePoint Timer Job Administration project on CodePlex
  • Get-SPConfig project on CodePlex: automates configuration and log collection in a SharePoint 2010 environment
  • SharePoint Solution Deployer (SPSD) project on CodePlex: helps automating Solutions (WSP) deployment over multiple environments
  • The famous Sysinternals Tools
  • SharePoint Audit Viewer project on CodePlex

Development

  • Developing Applications for SharePoint 2007
  • Developing Applications for SharePoint 2010
  • SharePoint 2013 Development Overview
  • SharePoint Software Factory: Visual Studio Extension to help with SharePoint Development
  • Community Kit for SharePoint: Development Tools Edition: Visual Studio Extension to help with SharePoint Development
  • SharePoint 2010 Developer Dashboard: built-intool provding developers with real time metrics over object instantiations and SQL queries
  • SharePoint 2010 Developer Dashboard Visualizer project on CodePlex
  • SharePoint 2013 Developer Dashboard: Updated with client-side metrics
  • SPDisposeCheck: The well-known tool to diagnose lack of object disposal causing memory leaks or overdisposal causing other issues
  • Telerik‘s JustDecompile: A free .Net Decompiler
  • JetBrain‘s dotPeek: Another free .Net Decompiler
  • SharePoint AJAX Toolkit for SharePoint 2010 and 2013 project on CodePlex
  • CLR Profilers for the .NET Frameworks 2.0 and 4.0: Enables Managed Code profiling
  • Power Toys for .NET Compact Framework 3.5: Multiple tools including a Managed Code Profile specific to .Net Framework 3.5
Advertisements

Install and Configure the Office 365 PowerShell Cmdlets:

23 Monday Sep 2013

Posted by ken zheng in Ofice365, PowerShell, Sharepoint

≈ Leave a comment

Tags

Office365, PowerShell, Sharepoint 2013

You need either Windows 7 or Windows Server 2008 R2 with Windows PowerShell and .NET Framework 3.5.1 or higher installed. You’ll also need to download and install the Office 365 Sign-in Assistant. Here’s the links to either the 32 or 64 bit version:
Microsoft Online Services Sign-In Assistant (IDCRL7) – 32 bit version
Microsoft Online Services Sign-In Assistant (IDCRL7) – 64 bit version

Next you will download and install the cmdlets. After you download the appropriate file, double-click the “AdministrationConfig.msi” file.
Microsoft Online Services Module for Windows PowerShell (32-bit version)
Microsoft Online Services Module for Windows PowerShell (64-bit version)

If you got the following error message (although Microsoft Online Services Sign-In assistant version 7.0 is installed)

“In order to install Windows Azure Active Directory Module for Windows PowerShell, you must have Microsoft Online Services Sign-In Assistant version 7.0 or greater installed on this computer”

The workaround solution is to install instead the Microsoft Online Services Sign-In Assistant for IT Professionals BETA:

http://www.microsoft.com/en-us/download/details.aspx?id=39267

The installation adds the shortcut titled “Microsoft Online Services Module for Windows PowerShell” to your desktop and the Start Menu. Once the module is installed you can try connecting to Office 365 by following the directions in the previous blog.

If you are facing any problems you may have to enable PowerShell scripts to run on your computer. Type the following command after opening PowerShell as an Administrator:

Get-ExecutionPolicy

If the results say anything other than RemoteSigned then run this command:

Set-ExecutionPolicy RemoteSigned

That should enable your computer to connect PowerShell to Office 365. If it doesn’t then go through this TechNet article for further troubleshooting:
http://technet.microsoft.com/en-us/library/cc952756%28EXCHSRVCS.149%29.aspx

Scripting your connection

Once you have finished the above you’re ready to actually connect to your Office365 domain. Here is the syntax that you will need to run:

Import-Module MSOnline
$O365Cred = Get-Credential
$O365Session = New-PSSession –ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $O365Cred -Authentication Basic -AllowRedirection
Import-PSSession $O365Session -AllowClobber
Connect-MsolService –Credential $O365Cred

The file at the right contains the code above. If you download it and run it from within Powershell it will get you connected. Otherwise you can use the above to create your own or copy line by line into Powershell.

Manage order of User Profile Properties

10 Thursday May 2012

Posted by ken zheng in PowerShell, Sharepoint

≈ 4 Comments

Tags

PowerShell, SharePoiint 2010, User Profile

I am not sure who design the page, you have to click the up arrow next to the property to move it up one and each time you click the arrow the page refreshes so you have to scroll back down before you can do it again and if you have to move the property by 50 positions that 50 clicks and 50 page refreshes –

 

image

 

Below script can change the order for you, and the later part is to display the order of the properties for reference

Add-Type -Path "c:\program files\common files\microsoft shared\web server extensions\14\isapi\microsoft.office.server.dll"
$mySiteUrl = "http://yourmysitegoeshere"
$site = Get-SPSite $mySiteUrl
$context = Get-SPServiceContext $site
$upConfigManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context)
$profilePropertyManager = $upConfigManager.get_ProfilePropertyManager()
$upConfigManager.GetProperties().SetDisplayOrderByPropertyName("SIMCARD",5510)
$upConfigManager.GetProperties().CommitDisplayOrder() 


$AllProperties = $upConfigManager.GetProperties()

foreach($prop in $AllProperties)
{
 
$DisplayName = $prop.DisplayName
 
$DisplayOrder = $prop.DisplayOrder

 
write-host $DisplayName, ";", $DisplayOrder, ";" 
 
}
write-host "Finished."

					

The ‘Microsoft.Jet.OLEDB.4.0’ provider is not registered on the local machine.

21 Monday Nov 2011

Posted by ken zheng in PowerShell

≈ 1 Comment

Tags

PowerShell

I am using Win 7 X64 bit operation system, when I run the PowerShell script, I got the error. In Fact, the OLEDB dll has been installed and if you search “Msjet40.dll”. Here is the link for how to determine the Jet 4.0.

Because Jet 4.0 only have 32 bit version, so to use the object. You need to run your program on X86 bit.

image

I Deleted A Site Collection in Production Sever

28 Thursday Jul 2011

Posted by ken zheng in Sharepoint

≈ Leave a comment

Tags

PowerShell, SharePoiint 2010, Site Collection

In one early morning, I am doing multi tasks. I think I am in the sub site but actually I am in the top level. When I deleted that site, some calls coming in.

Fortunately, there is PowerShell cmd you can restore deleted site collection.This cmdlet was introduced in Microsoft SharePoint Server 2010 with Service Pack 1 (SP1) and Microsoft SharePoint Foundation 2010 with Service Pack 1 (SP1).

  • Get-SPDeletedSite
  • Restore-SPDeletedSite
  • Remove-SPDeletedSite

Run Use Get-SPDeletedSite to find Identity (GUID) then

Restore-SPDeletedSite -Identity 610857cb-8414-4a89-8bf3-ad3628f6c86c

All deleted sub site can be retrieved from Site Recycle Bin!

Click the Site Collection Recycle Bin (Site Actions > Site Settings > Recycle Bin) under Site Collection Administration:

Select “Deleted from end user Recycle Bin”

Select the checkbox next to the site to restore and click “Restore Selection” from the menu above. Once completed, navigate to the newly restore site:

 

Thanks Microsoft for saving my job!

Import-SPWeb : Cannot import site.

28 Tuesday Jun 2011

Posted by ken zheng in PowerShell, Sharepoint

≈ 1 Comment

Tags

Import-SPWeb, PowerShell, SharePoiint 2010

Error:
FatalError: Cannot import site. The exported site is based on the template STS#0 but the destination site is based on the template SPS#0. You can import sites only into sites that are based on same template as the exported site.

Import-SPWeb : Cannot import site. The exported site is based on the template STS#0 but the destination site is based on the template STS#1. You can import sites only into sites that are based on same template as the exported site.

Issue:-
In SharePoint 2010 when we use Powershell Commands to Export / Import site collections we get Site Template mismatch errors as now SP 2010 needs to have the same template for the site while importing which was used on the site exported.
In such scenarios when you have migrated from SPS 2003 -> MOSS 2007 -> SP 2010 there will be many old Site templates which are now Obsolete in SP 2010 and not available, due to which it will be very difficult to Import the site.

Resolution / Workaround:-
1. Central Admin -> Application Management -> Create Site Collection
2. During Template selection go to ‘Custom’ Tab -> Select Template Later…..
3. Run the Import-SpWeb command now and it should import the site collection without any issues.
As we are not selecting any template while creating a Site Collection, it automatically pics up the template which is using while importing the Site Collection.

The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered

02 Thursday Jun 2011

Posted by ken zheng in PowerShell, Sharepoint

≈ Leave a comment

Tags

PowerShell

Problem

When you run powershell on your server you get the following error:

The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered.

clip_image001

Solution

Make sure the logged in user has rights to the SharePoint_Configuration database

    • SharePoint_Shell_Access
    • DB_owner (try reducing the privileges after you get it working in order to support “least privileges”

clip_image002

Power Shell Script to Check HREF ULR in InfoPath form

08 Wednesday Dec 2010

Posted by ken zheng in PowerShell

≈ Leave a comment

Tags

InfoPath, PowerShell

We have a system which contains thousands of InfoPath forms, the template files are in the SharePoint site. And some forms cannot be opened after some users editing because of the wrong InfoPath Cache. So I wrote the little scrip to loop all the forms and get HREF string to check if the url is valid.

Param($Path = "D:\Temp",[switch]$verbose)

Write-Host

$fc = new-object -com scripting.filesystemobject
$folder = $fc.getfolder($path)
$strFinder = "http.*xsn"
$logfile = "D:\Temp\NPILog.txt"

function ProcessFiles([string]$folderpath) {

Write-host " + Processing all Forms from: $folderpath"
$Forms = dir $folderpath "*.xml"

		Write-host "  + $($Forms.count) Forms found"
		Write-host " + Processing all $($Forms.count) Forms located at: $folderpath" -fore White

			foreach($Form in $Forms)
			{
				Write-Host "  + +	Processing Form: $($Form.Name)" -fore White
				Find-String  $strFinder $Form.FullName
			}	
	
}

function Find-String($find, $path)
{
    $url_values = New-Object System.Collections.ArrayList
	$i = 0
	echo "Finding string `"$find`" in file contents and file names of path: $path"
	ls $path | select-string $find -list |% { echo "Processing contents of $($_.Path)"; (get-content $_.Path) |% { [regex]::matches($_, $find) |%{$url_values.Add($_.value); $i++}} }
    echo $url_values[0]
	if(Check-URL $url_values[0])
	{
		Write-Host "$($path) href is fine"
	}
	else
	{
		Write-Host "$($path) href is wrong" -foregroundcolor red -backgroundcolor yellow
		Add-Content $logfile "$($path) href is wrong, checked at $(Get-Date)"

	}
}

function Check-URL($url)
{
	$urlIsValid = $false
	try
	{
		$request = [System.Net.WebRequest]::Create($url)
		$request.Credentials = [System.Net.CredentialCache]::DefaultCredentials;
		$request.Method = 'HEAD'
		$response = $request.GetResponse()
		$httpStatus = $response.StatusCode
		$urlIsValid = ($httpStatus -eq 'OK')
		$tryError = $null
		$response.Close()
	}
	catch [System.Exception] {
		$httpStatus = $null
		$tryError = $_.Exception
		$urlIsValid = $false;
	}
    
	return $urlIsValid
}

Write-Host "$($folder.ShortName) "
Write-Host "  + Total Folders: $($folder.SubFolders.Count)"
foreach ($i in $folder.SubFolders) {
	Write-Host "  + Folder Name: $($i.ShortName)"
	ProcessFiles($i.Path)
}

PowerShell Replace Script

17 Wednesday Nov 2010

Posted by ken zheng in PowerShell

≈ Leave a comment

Tags

PowerShell

Below is the script that loop folder to replace the string in all XML files.

The string I need to place is the href link in InfoPath form. So it look like

href="http://ppp/ppp/template.xsn"

 

So I use the way to replace string in between the characters

'bleeeh' -replace '(bl).+(h)','$1cc$2' 

 

This will print out: blcch

The whole script is look like:

Param($Path = "D:\Temp",[switch]$verbose)

Write-Host

$fc = new-object -com scripting.filesystemobject
$folder = $fc.getfolder($path)
$strFinder = '(href="http://).+(template.xsn)'

function ProcessFiles([string]$folderpath) {

Write-host " + Processing all Forms from: $folderpath"
$Forms = dir $folderpath "*.xml"

Write-host "  + $($Forms.count) Forms found"
Write-host " + Processing all $($Forms.count) Forms located at: $folderpath" -fore White

	foreach($Form in $Forms)
	{
		$strReplace ="$1XXX$2"
		Write-Host "  + +	Processing Form: $($Form.Name)" -fore White
		if($Form.Name.Contains("IPP")){$strReplace ='$1IPP$2'}
		elseif($Form.Name.Contains("EDP")){$strReplace ='$1EDP$2'}
		Replace-String  $strFinder $strReplace $Form.FullName
	}	
}

function Replace-String($find, $replace, $path)
{
	echo "Replacing string `"$find`" with string `"$replace`" in file contents and file names of path: $path"
	ls $path | select-string $find -list |% { echo "Processing contents of $($_.Path)"; (get-content $_.Path) |% { $_ -replace $find, $replace } | set-content $_.Path -Force }
}

Write-Host "$($folder.ShortName) "
Write-Host "  + Total Folders: $($folder.SubFolders.Count)"
foreach ($i in $folder.SubFolders) {
	Write-Host "  + Folder Name: $($i.ShortName)"
	ProcessFiles($i.Path)
}

 

Love PowerShell

Use PowerShell Script as Schedule Task

08 Friday Oct 2010

Posted by ken zheng in PowerShell

≈ Leave a comment

Tags

PowerShell

Just create a schedule task as usual and put below command in

C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe –File 
S:\chkzheng\PowerShellLibrary\Get-SPSite.ps1 -url http://chisps71

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

← Older posts

Pages

  • About Ken
  • Ken’s CV

Blog Stats

  • 1,635,085 hits

.Net 3.5 5566 AJAX BCS BDC C# Calendar Content Type CSS Custom Page Document ID Fast Search favicon Feature IIS InfoPath infopath form JavaScipt JavaScript jQuery LINQ Listview Managed Property Master Page MCP MCPD migration MOQ MySite Page Layout PowerShell Proxy Search Search Scope SharePoiint 2010 SharePoiint 2010; Search SharePoin Sharepoint Sharepoint 2007 SharePoint2007 Sharepoint 2010 Sharepoint Search Silverlight Site Collection Site Definition Site Master Page site templates SPDisposeCheck SPD workflow SPSiteDataQuery SPUser SQL SSP stored procedure STSADM survey Tab TechEd Tech ED TSQL User Profile User Profiles Synchronization Service;SharePoint 2010 vs 2008 vs 2010 vs2010 WCF web.config webpart Web Part Web Service windbg workflow XML XSL XSLT

Archives

  • March 2016
  • April 2014
  • March 2014
  • February 2014
  • December 2013
  • October 2013
  • September 2013
  • March 2013
  • February 2013
  • August 2012
  • June 2012
  • May 2012
  • April 2012
  • February 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • June 2011
  • May 2011
  • April 2011
  • March 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • October 2010
  • September 2010
  • August 2010
  • July 2010
  • June 2010
  • May 2010
  • April 2010
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • October 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • January 2008

Twitter Updates

  • @telstra @outage @3125 internet cable still not working since 8:30 am 6 months ago
  • @Telstra is internet cable service still down in Burwood Vic 3125? Have been issue for a day! 6 months ago
  • Anyone uses @Nintex Workflow for SharePoint online has email issue? all our external email actions are hanging since yesterday. 9 months ago
  • @Nintex Hi, is your Workflow External Email service is down? Since yesterday afternoon, no email being sent out usi… twitter.com/i/web/status/9… 9 months ago
  • @Nintex just wonder if there is any SharePoint online workflow server issue right now? All workflows are not reachable 1 year ago
Locations of visitors to this page

Blogroll

  • E-books Library
  • My Linkedin
  • SharePoint Community
  • SharePoint Developer Center
  • Silverlight Show
February 2019
M T W T F S S
« Mar    
 123
45678910
11121314151617
18192021222324
25262728  
Advertisements

Create a free website or blog at WordPress.com.

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy