sharepointking

Just another WordPress.com site

Category Archives: bulk user

Add Bulk user using powershell script – sharepoint 2010

$0 = $MyInvocation.MyCommand.Definition # Get complete file path (eg: D:\VJESPMasterScript\VJESPMaster.ps1)
$dp0 = [System.IO.Path]::GetDirectoryName($0) # Get current Directory file path (eg: D:\VJESPMasterScript)
$bits = Get-Item $dp0 | Split-Path -Parent # Get current Drive (eg: D:\)

## Start logging
$LogTime = Get-Date -Format yyyy-MM-dd_hh-mm
$LogFile = “$dp0\AF.rtf”

## check to ensure Microsoft.SharePoint.PowerShell is loaded if not using the SharePoint Management Shell
$snapin = Get-PSSnapin | Where-Object {$_.Name -eq ‘Microsoft.SharePoint.Powershell’}
if ($snapin -eq $null)
{
Write-Host “Loading SharePoint Powershell Snapin…”
Add-PSSnapin “Microsoft.SharePoint.Powershell”
}

#This takes care of the disposable objects to prevent memory leak.
Start-Transcript $logfile

New-SPUser -UserAlias “domain\trial5535” -web “https://www.mysharepointserver.com/managedpath/collection/site” -Group “Interim Site Owners”

New-SPUser -UserAlias “domain\tryenr1” -web “https://www.mysharepointserver.com/managedpath/collection/site” -Group “Interim Site Owners”

Stop-Transcript