Showing posts with label SharePoint 2013. Show all posts
Showing posts with label SharePoint 2013. Show all posts

Thursday, 7 April 2016

Create user profile from AD using powershell

Hi,

After a long time. Coming to straight point, how do we create user profiles automatically for those AD users available.

Case : During one of the implementation of my project I came through one scenario in which I need to get all AD users and iterate through it. Check if user profile exists for that AD user or not? If not create user profile for it. I am pasting my script here. Please find below powershell script :

import-module activedirectory
$users = Get-ADUser -Filter * -SearchBase "OU=TESTGroup,DC=YOURADFOREST,DC=COM"

$spsite = new-object Microsoft.SharePoint.SPSite(<YOUR MY SITE HOST URL>)
$context = [Microsoft.Office.Server.ServerContext]::GetContext($spsite)
$pmanager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)

ForEach($user in $users)  
{    
   Write-Output('' + $user.UserPrincipalName)
   $exists = $pmanager.UserExists($user.UserPrincipalName)
   if ($exists -eq $false)
   {
     Write-Output('Profile for this user is not created...')
     $pmanager.CreateUserProfile($user.UserPrincipalName)
     $up = $pmanager.GetUserProfile($user.UserPrincipalName)
     $up.CreatePersonalSite()
   }
}

Note: Prior to execute this script do test Get-ADUser, if it throws any error then you need to install AD feature. To do so you can use these 2 commands

Import-Module ServerManager

Add-WindowsFeature RSAT-AD-PowerShell

In above given code snippet

OU=TESTGroup, TESTGroup is group name.
DC=YOURADFOREST YOURADFOREST is your forest name

That's it from my side. Hope this helps needy one. Thanks.

Sunday, 5 July 2015

How to use iframes in SharePoint 2013


Hello Everyone.
Yes after a long time I m back with SharePoint blogs again. But excited to highlight one of the new feature introduced in SharePoint 2013 i.e. IFrame support for SharePoint 2013.

Now SP2013 supports directly IFrame component. I will guide you step by step :
  1. You need to create new entry of your domain into HTML Field Security :
    1. One can do this by simply navigating to Site Settings
    2. You can find HTML Field Security under Site Collection Administration
    3. Click on that and you will on HTML Field Security configuration page. Add your domain into allow iframes from this domain textbox and click Add. If it is already there then no need to add. After adding domain name click on Ok button.
  2. Now navigate to page where you want IFrame component
  3. Click on Settings > Edit Page
  4. Click on Add a WebPart link.
  5. From WebPart Gallerty select Media and Content type.
  6. Select Content Editor WebPart from there and click Add button
  7. After WebPart is added click on Click here to add new content link
  8. From ribbon select Edit Source option.
  9. Add embeded code or IFrame element here and click Ok button.
  10. Click on Stop Editing option from ribbon.

That's it you can view content inside IFrame there. I hope you will find this post helpful. Will modify this post with live example later on. Thanks for reading this post. And will post more things soon.