Article archive
Merge Date and Time to DateTime
27/11/2013 11:23
Following date and time formats are used in InfoPath forms (value from Date or Time picker)
$dateString = "2013-11-27"
$timeString = "15:20:00"
$timeSplit = $timeString.Split(':');
$timeSpan = new-object System.TimeSpan($timeSplit[0],$timeSplit[1], $timeSplit[2]);
$timeSpan
$dateTime =...
Add user to sharepoint group
26/11/2013 12:41
function AddUserToGroup
{
#Add user(s) to sharepoint security group
param($webUrl, [array]$users, $groupName)
"=================================="
$script:MyInvocation.MyCommand.Name
"=================================="
$web = Get-SPWeb $webUrl
$group = $web.SiteGroups[$groupName]
if($group -and...
Create default site groups on site collection
26/11/2013 12:37
#Creates site collections
function CreateTeamSiteCollection
{
param($siteUrl, $title, $admins)
"=================================="
$script:MyInvocation.MyCommand.Name
"=================================="
if(-not $title)
{
$title = $siteUrl
}
$site = Get-SPSite -Identity $siteUrl -ErrorAction...
Set web properties
22/11/2013 15:13
#Set web properties as hashtable
$properties = New-Object hashtable
$properties.Add("property1name", "someValue");
$properties.Add("property2name", "otherValue"));
& $location\SetWebProperties.ps1 -webUrl $webUrl -properties $properties
SetWebProperties.ps1 file with param
#Adds...
Activate feature with Event receiver by Powershell
21/11/2013 14:20
#There is a problem with Enable-SPFeature command in case of having event receiver in the feature. Feature Activated event is not fired. This is used as workaroud..
#inspired by...
Set site logo in Sharepoint
21/11/2013 13:56
#Logo file was uploaded to $logoUrl by 'Upload' script
#Sets logo for web
param($webUrl, $logoUrl)
Heading $script:MyInvocation.MyCommand.Name
$web = Get-SPWeb $webUrl
"Setting logo '{0}' for '{1}...'" -f $logoUrl, $webUrl
$web.SiteLogoUrl = $logoUrl
$web.Update()
$web.Dispose()
Add Composed Looks
21/11/2013 13:55
#Sets logo for web
param($webUrl, $themeName, $themeFileName, $displayOrder)
$web = Get-SPWeb $webUrl
$themeUrl = "/_catalogs/theme/15/" + $themeFileName
$composedLookList = $web.GetList($webUrl+"/_catalogs/design/")
$item = $composedLookList.AddItem();
"Adding item '{0}' to...
Add site collection administrators
21/11/2013 12:19
$admins = @("testuser", "lukas", "peter")
$site = Get-SPSite -Identity $siteUrl
foreach($admin in $admins)
{
$userName = $env:UserDomain + "\" + $admin
"Adding '{0}' to site collection administrators" -f...
Get more properties for Active Directory user
08/11/2013 15:52Find user in Active Directory
24/10/2013 16:46
Find User in Active Directory
Add References to
System.DirectoryServices;
System.DirectoryServices.AccountManagement;
using System.DirectoryServices;
using System.DirectoryServices.AccountManagement;
public string GetAdUser(string userName)
{
using...
Items: 151 - 160 of 384