string url = "https://sharepoint/sites/teamsite";string domain = "myDomain";string login = "myLogin";string pwd = "myPassword"; // feature id for MySite Newsfeed webpart:Guid feature = new Guid("6928B0E5-5707-46a1-AE16-D6E52522D52B");using (var ctx = new ClientContext(url)){ ctx.AuthenticationMode = ClientAuthenticationMode.Default; ctx.Credentials = new System.Net.NetworkCredential(login, pwd, domain); var features = ctx.Site.Features; ctx.Load(features); ctx.ExecuteQuery(); features.Add(feature, true, FeatureDefinitionScope.None); ctx.ExecuteQuery();}
$destinationUrl = "https://sharepoint/sites/teamsite/documents"$file = get-childitem "e:\tmp\document.txt"$webclient = New-Object System.Net.WebClient $webclient.UseDefaultCredentials = $true$webclient.UploadFile($destinationUrl + "/" + $file.Name, "PUT", $file.FullName)
add-pssnapin microsoft.sharepoint.powershell $spserver = get-spserver | ?{$_.role -eq "Application"} foreach ($server in $spserver) { $name = [string]::concat("\\", $server.name) write-host "Performing IIS Reset on Server:"$server.name iisreset $server.Name write-host "Stopping SPTimerV4 on Server:"$server.name $stat = sc.exe $name stop sptimerv4 $stat = sc.exe $name query sptimerv4 while ($stat -match "STOP_PENDING") { write-host "Stopping" $stat = sc.exe $name query sptimerv4 start-sleep 4 } write-host "Starting SPTimerV4 on Server:"$server.name $stat = sc.exe $name start sptimerv4 $stat = sc.exe $name query sptimerv4 while (-not $stat -match "RUNNING") { write-host "Starting" $stat = sc.exe $name query sptimerv4 start-sleep 4 } write-host "SPTimerV4 started on Server:"$server.name}
(function () { var overrideCtx = {}; overrideCtx.Templates = {}; overrideCtx.OnPostRender = [ HighlightRowOverride ]; overrideCtx.Templates.Fields={ "Colour":{"View":RenderColour}} SPClientTemplates.TemplateManager.RegisterTemplateOverrides (overrideCtx);})();function RenderColour(ctx) { var link = ctx.displayFormUrl + "&ID=" + ctx.CurrentItem.ID + "&source=" + encodeURIComponent(window.location.href); var text = "< a class='ms-core-suiteLink-a' href='" + link + "'>< img src='/_layouts/15/images/icgen.gif'>"; return text;}function HighlightRowOverride(inCtx) { for (var i = 0; i < inCtx.ListData.Row.length; ++i) { var listItem = inCtx.ListData.Row[i]; var iid = GenerateIIDForListItem(inCtx, listItem); var row = document.getElementById(iid); if (row != null) { row.style.backgroundColor = listItem.Colour; } } inCtx.skipNextAnimation = true;}
$followedSite = „https://sharepoint/sites/news“$loginName = „roloff“$profile = $upm.GetUserProfile($loginName)$manager = New-Object Microsoft.Office.Server.Social.SPSocialFollowingManager($profile)$actorInfo = New-Object Microsoft.Office.Server.Social.SPSocialActorInfo$actorInfo.ContentUri = $followedSite$actorInfo.ActorType = 2 # SPSocialActorType.Site$manager.Follow($actorInfo)
$adGroup = "" # AD Group with MySite users$siteURL = "" # any local SharePoint Site will do$members = Get-ADGroupMember -Identity $adgroup -Recursive | sort name# get UserProfileManager$serviceContext = Get-SPServiceContext -site $siteURL -ErrorAction Stop$upm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext) -ErrorAction Stopforeach ($member in $members){if ($upm.UserExists($member.SamAccountName)){ $profile = $upm.GetUserProfile($member.SamAccountName) $perssite = $profile.PersonalSite if ($perssite -eq $null) { # either this $profile.CreatePersonalSite(1031) # should work in most cases # or this # $profile.CreatePersonalSiteEnque($true) # will work in all cases; gets language from mysite host $perssite = $profile.PersonalSite if ($perssite -eq $null) { # do some error handling } }}}
Get-SPDatabase | where-object { $_.TypeName -eq "Content Database" } | select Displayname, @{Name="Mbytes";Expression={$_.DiskSizeRequired/ 1Mb}}
=";#choice 1;#choice 2;#choice 3;#"
# URL to your MySite web application$MySiteWebUrl = "https://mysite.collaboration-2-go.net" # where to find users in the AD$searchbase="DC=collaboration-2-go,DC=net" # required if server domain and user domain are different$dc="my_domain_controller" # required if server language is English and# MySite language is different$culture = "de-DE"$webapp = Get-SPWebApplication -identity $MySiteWebUrl[System.Threading.Thread]::CurrentThread.CurrentUICulture = $culture foreach ($site in $webapp.Sites){ # Get Active Directory Information $login = $site.Owner.LoginName if ($login.contains("\")) { $login = $login.substring($login.indexof("\") + 1) } $ldapfilter = "(SamAccountName=" + $login + ")" $aduser = Get-ADUser -LDAPFilter $ldapfilter -SearchBase $searchbase -Server $dc $displayName = $aduser.GivenName + " " + $aduser.Surname if ($displayName -eq " ") { $displayName = $site.owner.DisplayName } if ($site.RootWeb.WebTemplate -eq "SPSPERS") # ignore MySite host { # more sophisticated approach is possible but # I'm not sure about the blog URL foreach ($web in $site.AllWebs) { if (($web.WebTemplate -eq "BLOG") -and ($web.Title -eq "Blog")) { $title = "Blog von " + $displayName $web.Title = $title $web.Update() } $web.Dispose() } } $site.Dispose()}
$web = Get-SPWeb https://sharepoint/sites/blogwrite-host $web.Properties["ms-blogs-skinid"]$web.Properties["ms-blogs-skinid"] = 1$web.Properties.update()
Merge-SPLogFile -Path C:\tmp\FarmLog.log
Merge-SPLogFile -Path C:\tmp\FarmLog.log -Correlation b572479c-ce57-10ce-c901-ce456a0284dc
Merge-SPLogFile -Path C:\tmp\FarmLog.log -StartTime "28.07.2013 00:00" -EndTime "28.07.2013 23:59"
http://yourhost/_layouts/closeConnection.aspx?loginasanotheruser=true
' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' URL ListDim urls(3)urls(1)="https://portal/sites/project1"urls(2)="https://portal/sites/project2"urls(3)="https://portal/sites/project3"Dim servers(2)servers(1) = "server1"servers(2) = "server2"Dim PingReplyPingReply = "Reply from"Dim TargetUrlTargetUrl = "portal"Dim outFileoutFile="c:\WarmUp\WarmUp2013.log"' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''On error resume next' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Codedim fsodim startTimestartTime = Now'DeleteLogAddToLog "------------------------------------------------"set fso = CreateObject("Scripting.FileSystemObject")For Each server in servers If server <> "" Then AddToLog "---------------- " & UCase(server) hostfile = "C:\Windows\System32\drivers\etc\hosts-" & server fso.CopyFile hostfile, "C:\Windows\System32\drivers\etc\hosts" PingResult TargetUrl WarmUp() End IfNextAddToLog "---------------- RESET"fso.CopyFile "C:\Windows\System32\drivers\etc\hosts-original", "C:\Windows\System32\drivers\etc\hosts"PingResult TargetUrlset fso = NothingAddToLog "---------------- Summary"minTime = UBound(urls) * UBound(servers) * 5duration = datediff("s", startTime, now)AddToLog "URLs: " & UBound(urls)AddToLog "Minimal Time: " & minTimeAddToLog "Duration (s): " & durationIf duration > (minTime + 5) Then AddToLog "Warning!"End IfAddToLog "------------------------------------------------"' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Subssub WarmUp() dim ie set ie = CreateObject("InternetExplorer.Application") ie.Visible = 0 For Each u1 In urls if u1 <> "" then AddToLog u1 ie.Navigate2 u1 WScript.Sleep(5000) Do while IE.readystate <> 4 loop end if Next ie.Quit set ie = Nothingend subsub DeleteLog() outFile="c:\svn\WarmUp2013.log" Set objFSOFile=CreateObject("Scripting.FileSystemObject") objFSOFile.DeleteFile outFileend subsub AddToLog(txt) set objFSOFile=CreateObject("Scripting.FileSystemObject") set objFile = objFSOFile.OpenTextFile(outFile, 8, True) objFile.Write Now & " - " & txt & vbCrLf objFile.Close wscript.echo txtend subsub PingResult(host) dim objShell dim objExec set objShell = CreateObject("WScript.Shell") set objExec = objShell.Exec("ping -n 1 -w 1000 " & host) pr = objExec.StdOut.ReadAll pr = mid(pr, InStr(pr, PingReply)) pr = left(pr, InStr(pr, ":") - 1) AddToLog pr set objShell = Nothing set objExec = Nothingend sub