Function Create-MySite
{
[CmdletBinding()]
Param
(
[Parameter(Mandatory = $True,Position=2,valueFromPipeline=$true)][String]$Username,
[Parameter(Mandatory = $True,Position=1)][String]$MySiteRootURL
)
[void][reflection.assembly]::Loadwithpartialname("Microsoft.Office.Server");
$site=new-object Microsoft.SharePoint.SPSite($MySiteRootURL);
try
{
$serviceContext = Get-SPServiceContext $site;
$upm = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext);
if($upm.UserExists($Username) -eq $false)
{
Write-Host "User $Username was not found in the profile store." -f yellow;
return;
}
$userProfile = $upm.GetUserProfile($Username);
if($userProfile.PersonalSite -eq $Null)
{
Write-Host "Creating MySite for user $Username" -f darkyellow;
$userProfile.CreatePersonalSite();
Write-host "Successfully created MySite for user $Username" -f green;
}
else
{
Write-Host "User $Username already has a MySite." -f darkgreen;
}
}
catch
{
Write-Host "Encountered an error creating a MySite for user $Username. Error:"$_.Exception -f Red;
}
finally
{
$site.Dispose();
}
}
Create-MySite -MySiteRootURL "http://url" -Username "domain\user"
Showing posts with label Sharepoint 2013;. Show all posts
Showing posts with label Sharepoint 2013;. Show all posts
Wednesday, October 14, 2015
Friday, October 9, 2015
Powershell script remove contenttypes from list
#Get site object and specify name of the library to look for in each site
$site = Get-SPSite http://URL
$lookForList = "ListName"
$ContentType = "CTName"
#Walk through each site and change content types on the list specified
$site | Get-SPWeb -Limit all | ForEach-Object {
write-host "Checking site:"$_.Title
#Check list exists
$docLibrary = $_.Lists[$lookForList]
#Remove unwanted content types from the list
if($docLibrary -ne $null)
{
$ctToRemove = $docLibrary.ContentTypes[$ContentType]
write-host "Removing content type" $ctToRemove.Name "from list" $docLibrary.Title
$docLibrary.ContentTypes.Delete($ctToRemove.Id)
$docLibrary.Update()
}
else
{
write-host "The list" $lookForList "does not exist in site" $_.Title
}
}
#Dispose of the site object
$site.Dispose()
Thursday, June 11, 2015
Export managed metadata
Get-SpServiceApplication | select DisplayName, ID
Get-SPServiceApplicationProxy | select DisplayName, ID
$mmsAppId = "GUID"
$mmsproxy = Get-SPServiceApplicationProxy -Identity GUID
Export-SPMetadataWebServicePartitionData -Identity $mmsAppId -ServiceProxy $mmsproxy -Path \\server\path\filename.bak
Get-SPServiceApplicationProxy | select DisplayName, ID
$mmsAppId = "GUID"
$mmsproxy = Get-SPServiceApplicationProxy -Identity GUID
Export-SPMetadataWebServicePartitionData -Identity $mmsAppId -ServiceProxy $mmsproxy -Path \\server\path\filename.bak
Monday, July 7, 2014
Security Token Service is down or showing errors?
Some examples of errors that may show up in your ULS log.
- An exception occurred when trying to issue security token: The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error (OR)
- Request for security token failed with exception: System.ServiceModel.ServiceActivationException: The requested service,'http://localhost:32843/SecurityTokenServiceApplication/securitytoken.svc/actas' could not be activated (OR)
- An exception occurred when trying to issue security token: The requested service,'http://localhost:32843/SecurityTokenServiceApplication/securitytoken.svc/actas' could not be activated
$h = Get-SPServiceHostconfig
$h.Provision()
$services = Get-SPServiceApplication
foreach ($service in $services) { $service.provision();
write-host $service.name}
Perform an IIS Reset and try to browse the STS, http://localhost:32843/SecurityTokenServiceApplication/securitytoken.svc
Subscribe to:
Posts (Atom)