PowerShell – Get User Profile Service info

# Get_UserProfileServices.ps1# Dump out any info I can glean from the User Profile Synch for SharePoint.## LukeB# http://technet.microsoft.com/en-us/library/ee721049.aspx#if ((Get-PSSnapin “Microsoft.SharePoint.PowerShell” -ErrorAction SilentlyContinue) -eq $null) {    Add-PSSnapin “Microsoft.SharePoint.PowerShell”}[void][System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”) $USERPROFILESERVICEPROXY  = “Microsoft.Office.Server.Administration.UserProfileServiceProxy”$USERPROFILEAPPLICPROXY     = “Microsoft.Office.Server.Administration.UserProfileApplicationProxy”$USERPROFILESERVICE              = “Microsoft.Office.Server.Administration.UserProfileServiceInstance”$SYNCHSERVICE           = “Microsoft.Office.Server.Administration.ProfileSynchronizationServiceInstance” ################################################################################################################ — helper functionfunction Get-SPfarmAdministrators {  $adminwebapp = Get-SPwebapplication -includecentraladministration | where {$_.IsAdministrationWebApplication}  $adminsite = Get-SPweb($adminwebapp.Url)  $AdminGroupName = $adminsite.AssociatedOwnerGroup  $farmAdministratorsGroup =…

0

PowerShell – sorting files by datestamp for SQL backup/restore

# Do-SPSQLbackupRestore.ps1# usage:# DO-SQLBackupRestore <Backup|Restore> [<SQL instance>] [<XMLfilename]>#[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SqlServer.SMO”) | Out-Null[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SqlServer.SmoExtended”) | Out-Null[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SqlServer.ConnectionInfo”) | Out-Null[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SqlServer.SmoEnum”) | Out-Null Function DO-SQLBackupRestore {  param ([string] $strSQLaction=”Backup”, [string] $strSQLServerInstance=”(local)”, [string] $DataBasesXML=”C:\BKP\BKP-SQLdatabases.xml”)   $SQLserver = New-Object (“Microsoft.SqlServer.Management.Smo.Server”) $strSQLServerInstance  $xml = [XML] (get-content $DataBasesXML)   ## dbName_yyyyMMddHHmmss.BAK  $stamp = “yyyyMMddHHmmss”  if ($strSQLaction.ToUpper() -eq “BACKUP”) {  DoBackupSQL $SQLserver $xml }  else { if…

3

PowerShell – decode an F5 BIG-IP cookie

# Decode-BigIPCookie.ps1# usage:# Decode-BigIPCookie “375537930.544.0000” function Decode-Cookie {  param ([string] $ByteArrayCookie)  ### F5 itself for the formula: http://support.f5.com/kb/en-us/solutions/public/6000/900/sol6917.html ### $poolcookie=”375537930.544.0000″ ###  if ($ByteArrayCookie -match ‘^(\d+)\.(\d+)\.0000$’) {   $ipEncoded   = [int64] $matches[1]   $portEncoded = [int64] $matches[2]    #  convert ipEnc to Hexadecimal   $ipEncodedHex = “{0:X8}” -f $ipEncoded   #  then split into an array of four    $ByteArray=@()   $ipEncodedHex -split…

1

SharePoint – is WinRM configured for remotePS?

# WinRMcheck.ps1# check the registry keys on the target server to see if WinRM has been configured.Set-StrictMode -Version latest#Requires -RunAsAdministrator# WinRM get winrm/config/client# WinRM get winrm/config/service # Server side requirements# Service WinRM must be running# The WinRM server configuration must have credssp enabled# HKLM:\Software\Microsoft\WIndows\CurrentVersion\WSMAN\Service\# DWORD auth_credssp = 1# Memory limits “should” be in place for…

3

SharePoint – Powershell replacement for the old STSadm RepairContentDatabase

Powershell replacements  are extremely useful. Test-SPContentDatabase gives you much of interest. However the key item you were looking for is the .REPAIR method. Get-SPContentDatabase | ForEach-Object {$_.Repair($true)} or use $false to just report and not repair. This is the same function as the STSADM cmdlet, but better because it pipelines all the ContentDB’s.

2

SharePoint – remoting PS

(not available for Win2003) you can configure for double-hop auth – do not know yet if we will need this. client:  WinRM QuickConfig  Enable-WSManCredSSP -Role Client -DelegateComputer TARGETMACHINE.DOMAIN.COM  or  Enable-WSManCredSSP -Role Client -DelegateComputer *server:  WinRM QuickConfig  Enable-WSManCredSSP -Role Server  ===================NOTE: the target SP server will need its PS shell space enlarged via the command Set-Item -Path WSMan:\localhost\Shell\MaxMemoryPerShellMB…

2

SharePoint – Search Admin

In the event of a server death, you may need to move your Search Admin to another server. This is actually fairly easy: $searchapp = Get-SPEnterpriseSearchServiceApplication “Sample Search Service Application”$admin = Get-SPEnterpriseSearchAdministrationComponent -SearchApplication $searchapp$admin | Set-SPEnterpriseSearchAdministrationComponent -SearchServiceInstance NewServerName –Force   But once you have moved Admin, your crawlers may not run until you also do…

1

SharePoint – Claims

Josh Gavant is writing a series on CLAIMS that makes it all rather clearer. http://blogs.msdn.com/b/besidethepoint/archive/2012/05/02/sharepoint-claims-ws-and-the-windows-identity-foundation-wif.aspx

0

SharePoint – migrate a sub-site into its own Site Collection

# Move-SPwebToNewSPsite.ps1## simple outline sample of how to migrate a sub-site into its own new Site Collection.# definately not comprehensive, but should give you an idea of what to do.# NO I have not exported Alerts or Workflows. Food for thought!# Add-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue $ExportShare = “\\SERVERNAME\Backup\oldWeb.CMP“$OldSPWebUrl = “http://intranet.contoso.com/SubSite“ $newMgdPath = “Sites”$newSPSiteName =…

10

SharePoint – Search PerformanceLevel

# you use Central Admin and click. But I was asked ‘how do you do that with PowerShell’? #SP2010Add-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinueGet-SPEnterpriseSearchService | Set-SPEnterpriseSearchService –PerformanceLevel “Maximum” #SP2007[void][System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)$SPfarm = [Microsoft.SharePoint.Administration.SPFarm]::Local$Search = $SPfarm.Services | where  {$_ -is [Microsoft.SharePoint.Search.Administration.SPSearchService]}$Search.PerformanceLevel = [Microsoft.SharePoint.Search.Administration.SearchPerformanceLevel]::Maximum$Search.Update()

0