Skip to main content

Posts

Showing posts from October, 2015

Create Bulck Site From using PowerShell in Office 365 /Online

1) Create CSV files based on your requirement and place desired location $csvLocation = ".\PS_SiteCollectionsToCreate.csv" $template = “STS#0” $siteUrl = “https://Yourcorp.sharepoint.com/sites/SPOTest2/” $username = “kamal@abc.com”#yourpassword Add-Type -Path “\Software\SharePoint 2013 Client Browser v1.7\Microsoft.SharePoint.Client.dll” Add-Type -Path “\Software\SharePoint 2013 Client Browser v1.7\Microsoft.SharePoint.Client.Runtime.dll” $password = Read-Host -Prompt “Enter password” -AsSecureString $ctx = New-Object Microsoft.SharePoint.Client.ClientContext ($siteUrl) $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password) $ctx.Credentials = $credentials $csv = Import-Csv $csvLocation ForEach ($site in $csv)  { $site = $($site.collumname) $webCreationInformation = New-Object Microsoft.SharePoint.Client.WebCreationInformation $webCreationInformation.Url = $site $webCreationInformation.Title = $site $webCr

Delete Site Using Power Shell In office 365/ Online

Add-Type -Path "\Software\SharePoint 2013 Client Browser v1.7\Microsoft.SharePoint.Client.dll" Add-Type -Path "\Software\SharePoint 2013 Client Browser v1.7\Microsoft.SharePoint.Client.Runtime.dll" $siteUrl = “https://yourcorp.sharepoint.com/sites/SPOTest2/Testite/” $username = "abc@abc.com" $password = Read-Host -Prompt "Enter password" -AsSecureString $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl) $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password) $ctx.Credentials = $credentials $web = $ctx.Web $ctx.Load($web) $ctx.ExecuteQuery() $web.DeleteObject() $ctx.ExecuteQuery()  Write-Host "----------------------------------------------------------------------------"  -foregroundcolor Green  Write-Host $web.Title "Site Deleted"  Write-Host "----------------------------------------------------------------------------"  -foregro

Office 365 Admin Tool -PowerShell

Copy the inline Command and Create PS1 File.  Function welcome{         Clear;         Write-Host "******************************************************"  -foreground Red         Write-Host "     Welcome to Office365 Administrator Tool          " -foreground Red         Write-Host "******************************************************"  -foreground Red } Function Login {         while(1){                 Welcome;                 Import-Module MsOnline;                 Write-Host "step 1" -ForegroundColor yellow;                 Write-Host " Enter Office365 account : " -nonewline;                 $global:adm_account = Read-Host ;                 Write-Host "--------------------------------------------------"-ForegroundColor yellow;                 Write-Host "step 2" -ForegroundColor yellow;                 Write-Host " Please enter your password : " -nonewline; # Login

Create Site Collection-Sub site Using Power Shell In SharePoint online /O365

Add-Type -Path "\Software\SharePoint 2013 Client Browser v1.7\Microsoft.SharePoint.Client.dll" Add-Type -Path "\Software\SharePoint 2013 Client Browser v1.7\Microsoft.SharePoint.Client.Runtime.dll" $siteUrl = “https://yourcorp.sharepoint.com/sites/SPOTest2/” $username = "abd@anc.com" $password = Read-Host -Prompt "Password" -AsSecureString $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl) $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password) $csvLocation = ".\PS_SiteCollectionsToCreate.csv" $ctx.Credentials = $credentials $csv = Import-Csv $csvLocation Write-Host "----------------------------------------------------------------------------"  -foregroundcolor Green Write-Host " Getting Data from CSV files" -foregroundcolor Green Write-Host "----------------------------------------------------------------------------"  -for

Power Shell command To get All users from SharePoint Online and Office 365

1) Please connect your Online Environment First Commands :  Open Windows PowerShell as an administrator (use Run as administrator). Run these commands to connect to Office 365. $credential = Get-Credential Import-Module MsOnline Connect-MsolService -Credential $credential Connect-SPOService -Url https://domainhost-admin.sharepoint.com -credential $credential Import-Module LyncOnlineConnector $sfboSession = New-CsOnlineSession -Credential $credential Import-PSSession $sfboSession Run Below command to get All users : Get-MSOLUser- All | Select DisplayName,FirstName,LastName,UserPrincipalName,MobilePhone,PhoneNumber,Office,Fax,StreetAddress,PostalCode,City,Country,State,Department, IsLicensed ,PreferredLanguage , Title , UsageLocation | Export-CSV C://MOSuser.csv Good Luck !

SP service code to Get the value from SharePoint List and and display another value based on drop down value selection

/ Function for getting commnets on page load  from Photographer lis $(document).ready(function() { // Photographer #1 $('select[title="Photographer1"]').change(function(e) { var selectedValue = $('select[title="Photographer1"] :selected').text(); $().SPServices({         operation: "GetListItems",         listName: "Photographers",         CAMLViewFields: "<ViewFields><FieldRef Name='Comments' /></ViewFields>",                         CAMLQuery: "<Query><Where><Eq><FieldRef Name='Name'/><Value Type='Text'>"+selectedValue+"</Value></Eq></Where></Query>",         completefunc: function (xData, Status) {          //alert(Status);             $(xData.responseXML).SPFilterNode("z:row").each(function() {              //PremiereDate = $(this).attr("ows_PremiereDate");  

Convert SharePoint Date in to ConvertDateToISO - And Use for Custom Save

-------------Code ------------------------------------------- function ConvertDateToISO(dtDate) { //************************************************* //Converts Javascript dtDate to ISO 8601 standard for compatibility with SharePoint lists //Inputs: dtDate = Javascript date format (optional) //************************************************* //alert("InISOCOnversion");   var d;   if (dtDate != null)  {      //Date value supplied           d = new Date(dtDate);   }   else  {      //No date supplied, Create new date object      d = new Date();   }   //Generate ISO 8601 date/time formatted string   var s = "";   //alert(d.getFullYear());    if(d.getFullYear)    {    //alert("FullYear");          s += d.getFullYear() + "-";     }     else     {      //alert("getyear");      var year= d.getYear() + 1900;      s += year + "-";             }   //s += d.getYear() + "-";   s += d.getMonth() + 1 + "-";   s

Java Script code to clear All value in SharePoint 2010, 2013

function ClearAllPeopleFields() { var blankValue= " "; clearpeoplefield("Retoucher",blankValue);     clearpeoplefield("Ingestor",blankValue);     clearpeoplefield("MR Contact #1",blankValue);     clearpeoplefield("MR Contact #2",blankValue);     clearpeoplefield("MR Contact #3",blankValue);     clearpeoplefield("MR Contact #4",blankValue);     clearpeoplefield("Legal Contact #1",blankValue);     clearpeoplefield("Legal Contact #2",blankValue);     clearpeoplefield("Legal Contact #3",blankValue);     clearpeoplefield("Legal Contact #4",blankValue);              clearpeoplefield("Account Manager",blankValue);              clearpeoplefield("Metadata",blankValue);              clearpeoplefield("Photo Editor",blankValue); }