Tuesday, October 4, 2016

SharePoint PowerShell

Update

DBATools is a free PowerShell module with over 180 SQL Server administration, best practice and migration commands included
https://dbatools.io/

Github
https://github.com/sharepoint

Codeplex
http://www.codeplex.com/site/search?TagName=Sharepoint

Add Online Modules
http://sharepoint-tricks.com/install-update-uninstall-cmdlets-for-sharepoint-online

More from The Cloud Engineer

https://thecloudengineer.blogspot.com/2016/09/powershell-toolbox-for-sharepoint.html

Older News

Strange Error
http://sharepoint.stackexchange.com/questions/17247/spsite-allwebs-returns-error

PowerShell Articles from Mike Smith
http://sharepointpromag.com/author/michael-t-smith

http://sharepointpromag.com/sharepoint-2010/inventorying-sharepoint-using-powershell

http://sharepointpromag.com/sharepoint/windows-powershell-scripts-sharepoint-info-files-pagesweb-parts

http://sharepointpromag.com/sharepoint-2013/exploring-sharepoint-users-groups-and-security-using-powershell

http://sharepointpromag.com/sharepoint/exploring-and-inventorying-sharepoint-using-powershell-part-4-finding-and-resetting-custo

http://techtrainingnotes.blogspot.cz/2011/06/sharepoint-how-to-change-default-home.html

Creating Content Types (and Site Columns) with PowerShell

http://www.rbradbrook.co.uk/blog/2013/03/10/creating-content-types-and-site-columns-with-powershell/

Log Info
http://zimmergren.net/technical/sp-2010-find-error-messages-with-a-correlation-id-token-in-sharepoint-2010

General Info

Great Tool
http://www.sapien.com/software/powershell_studio

Great site with a ton of scripts
http://blogs.technet.com/b/onescript/p/sharepoint.aspx

Just found but untested

http://social.technet.microsoft.com/wiki/contents/articles/20692.sharepoint-get-set-and-copy-user-profile-properties-using-powershell.aspx

ISE http://thecloudengineer.blogspot.com/2011/10/create-ise-enabled-for-sharepoint.html

Command Builder
http://www.microsoft.com/resources/TechNet/en-us/Office/media/WindowsPowerShell/WindowsPowerShellCommandBuilder.html

2013
Complete List - Index of Windows PowerShell cmdlets for SharePoint 2013
http://technet.microsoft.com/en-us/library/ff678226.aspx

2010
Complete List - Index of Windows PowerShell cmdlets for SharePoint 2010
http://technet.microsoft.com/en-us/library/ff678226(v=office.14).aspx

Great Reference to PowerShell in SharePoint 2010
http://technet.microsoft.com/en-us/library/ff678226.aspx

More from Powershell101
Users
http://powershell101.blogspot.com/2012/06/sharepint-users.html

Confirmed PS1 Examples

Enumerating SharePoint Permissions and Active Directory
New and improved http://briantjackett.com/archive/2013/07/01/powershell-script-to-enumerate-sharepoint-2010-or-2013-permissions-and.aspx

http://geekswithblogs.net/bjackett/archive/2009/04/24/the-power-of-powershell-and-sharepoint-enumerating-sharepoint-permissions-and.aspx

Capture and report on all SharePoint permissions through a site collection http://localgovernmentsharepoint.wordpress.com/2012/01/25/powershell-script-to-capture-and-report-on-all-sharepoint-permissions-through-a-site-collection/

Open Port Audit
http://gallery.technet.microsoft.com/Security-hardening-for-c425db1d

Potential Examples

Set AD changes needed for UPSA via powershell
http://blog.kuppens-switsers.net/2012/02/setting-replicating-directory-changes-using-powershell/

General Code from Engineers at PointBeyond
http://blog.pointbeyond.com/

Copy List
http://adicodes.com/copy-or-replace-list-items-in-powershell/#!

AD Lockout
http://mikefrobbins.com/2013/11/29/powershell-script-to-determine-what-device-is-locking-out-an-active-directory-user-account/

Move Site Collections
http://alinimer.com/2012/06/10/from-the-field-move-a-site-collection-to-new-content-db-with-new-managed-path/

Remove Unused Users
http://weblogs.asp.net/bsimser/archive/2013/02/12/powershell-tools-removing-orphaned-users-from-sharepoint.aspx

Long List of examples
http://powershellscripts.com/category.asp?cat=SharePoint

Adding users and claims to a site from PowerShell
http://blogs.msdn.com/b/brporter/archive/2010/12/02/adding-users-and-claims-to-a-site-from-powershell.aspx

Changing the Item-Level Permissions Settings for a Document Library requires PowerShell http://www.hersheytech.com/Blog/SharePoint/tabid/197/entryid/28/Default.aspx

Create a full site hierarchy
http://reality-tech.com/2012/03/07/scripts-to-create-scripts/

My Site
http://gallery.technet.microsoft.com/scriptcenter/Pre-Provision-SharePoint-ec781ee9

Thursday, October 8, 2015

Remote PowerShell

Updates

 

Security

Who’s afraid of PowerShell security?
https://blogs.technet.microsoft.com/ashleymcglone/2016/06/29/whos-afraid-of-powershell-security/

Defending Against PowerShell Attacks (2017)
https://blogs.msdn.microsoft.com/powershell/2017/10/23/defending-against-powershell-attacks/

ISE

PowerShell Remoting With Integrated Scripting Environment–ISE
http://blogs.technet.com/b/rmilne/archive/2015/02/02/using-exchange-powershell-remoting-with-integrated-scripting-environment-ise.aspx

Security

http://blogs.msdn.com/b/powershell/archive/2013/12/16/powershell-security-best-practices.aspx

Reflective DLL Loading with PowerShell:
http://www.youtube.com/watch?v=OAd68_SYQc8

Living off the Land:
http://www.youtube.com/watch?v=j-r6UonEkUw

Get-Help about_Group_Policy_Settings
http://technet.microsoft.com/en-us/library/jj149004.aspx

Constrained PowerShell Endpoints
http://www.youtube.com/watch?v=kmjJLKlL1Wg

PowerShell Language Specification:
http://www.microsoft.com/en-us/download/details.aspx?id=36389

Composing Command Arguments:
http://www.powershellcookbook.com/recipe/XoMw/run-programs-scripts-and-existing-tools

PowerShell Remoting over HTTPS with a self-signed SSL certificate
https://4sysops.com/archives/powershell-remoting-over-https-with-a-self-signed-ssl-certificate/

SharePoint

PowerShell Remoting for SharePoint 2010/2013
http://sharepoint-community.net/profiles/blogs/powershell-remoting-for-sharepoint

SharePoint 2010 with Windows PowerShell Remoting Step by Step
http://blogs.msdn.com/b/opal/archive/2010/03/07/sharepoint-2010-with-windows-powershell-remoting-step-by-step.aspx

Configure Remote PowerShell in SharePoint 2010
http://blogs.msdn.com/b/varun_malhotra/archive/2010/06/10/configure-power-shell-for-remote-use-of-sp-2010.aspx

Original Blog

There are several ways to connect and run PowerShell command remotely.  In this article I want to address the needs of many IT admins that just need quick PowerShell access to run a command or set of commands.

First step is to open your remote computer to PowerShell using GPOs or type

winrm quickconfig

image

Invoke-Command

Now using PowerShell you can run several commands but lets focus first on invoke command

image

Help Invoke-Command –examples is all you need.  Just copy the second example and fill in the blanks.

image

However this does have an annoying issues that we can quickly fix.  Using variables lets set both the computername and user

image

Just substitute the variables for computername and credentials and you are good to go.  Note that the user/password variable is secure for most users Winking smile but more on that later.

image

Enter-PSsession

Since we have variables set for computername and credentials this one is easy.

image

Now connected -Fun commands

image

[System.Net.Dns]::GetHostbyAddress("127.0.0.1")

[System.Net.Dns]::GetHostAddresses(“contoso.com")

image

get-wmiobject win32_service –computername 127.0.0.1

image

get-psdrive

cd hklm:\  (or any other drive)

Old School

Remember you can always type cmd to get the old classic command if needed.  Have Fun!

image

cd hklm:\get

References

Thanks always to Ed and Theresa Wilson for inspiration http://www.edwilson.com/

Good Articles on Remote PowerShell
http://technet.microsoft.com/en-us/magazine/gg981683.aspx
http://blogs.technet.com/b/heyscriptingguy/archive/2011/11/16/configure-powershell-remoting-and-use-remote-commands.aspx

system.net namespace

 http://msdn.microsoft.com/en-us/library/system.net.aspx

 http://msdn.microsoft.com/en-us/library/system.net.networkinformation.aspx

Old but not thrown out yet
http://blogs.msdn.com/b/powershell/archive/2008/05/10/remoting-with-powershell-quickstart.aspx

Tuesday, September 1, 2015

SharePoint Search Service Application PowerShell

 

Check the crawl status of all content sources in your SSA where SSA is search service application.

Get-SPEnterpriseSearchCrawlContentSource -SearchApplication "Search Service Application" | select Name, CrawlStatus | format-table –autosize

image

Total number of list items in a SharePoint Web Application

https://blogs.technet.microsoft.com/nishants/2012/05/04/total-number-of-list-items-in-a-sharepoint-web-application/