Monitoring disk space utilization using powershell

Monitoring disk space utilization is an important task in SharePoint to avoid the critical issues , we can implemented this using PowerShell to monitor the disk utilization , in this we did not kept any threshold conditions , we are generating only report in CSV format with list of all servers available  in our  environment.
We created a config file to add all servers that you want to know the disk space utilization.
Added the server names as per the below screen shot in the text file.


Please note: we are generating this only in CSV format, it is a plane text we cannot add any colors in our output file.

Add-PSSnapin microsoft.sharepoint.powershell
$resultsarray = @()
$computers = (Get-Content "d:\Allservers.txt")
$date = Get-Date -Format “dd-MM-yyyy”
foreach($computer in $computers)
{
if([string]::isnullorwhitespace($computer))
{
}
else
{
Write-Host $computer
 $drives = Get-WmiObject -ComputerName $computer Win32_LogicalDisk | Where-Object {$_.DriveType -eq 3}
 foreach($drive in $drives)
 {
  $contactObject = new-object PSObject
   $id = $drive.DeviceID
 $totalsize = [math]::round($drive.Size /1GB, 2)
 $freespace = [math]::round($drive.FreeSpace  / 1GB, 2)
 $usedspace= $totalsize-$freespace
 $freeprecent = [math]::round($freespace / $totalsize, 2) * 100
 $diskObject | add-member -membertype NoteProperty -name "Date" -Value $date
 $diskObject | add-member -membertype NoteProperty -name "Server Name" -Value $computer
 $diskObject | add-member -membertype NoteProperty -name "Drive" -Value $id
  $diskObject | add-member -membertype NoteProperty -name "Total GB" -Value  $totalsize     
   $diskObject | add-member -membertype NoteProperty -name "Used GB" -Value $usedspace   
 $diskObject | add-member -membertype NoteProperty -name "Free GB" -Value $freespace  
    $diskObject | add-member -membertype NoteProperty -name "% Free" -Value $freeprecent  
$resultsarray += $diskObject
}
}
}
$resultsarray| Export-csv -path "D:\diskreport_$date.csv" –notypeinformation

Delete SharePoint list items based on particular view using PowerShell


Send email to members of SharePoint Group using PowerShell

In this article we can see how to send email only from a particular group of people using power shell, it is very easy to user to remove/add new users whenever they want. In the below code we created a SharePoint Group with name “DotNetSharePoint”

add-pssnapin microsoft.sharepoint.powershell
$web = get-spweb -identity  "http://dotnetsharepoint.com/sites/SharePoint2013/BusinessUsers"
$groupss = $web.Groups.GetByName("DotNetSharePoint")
$emailgrouptoo =@()
foreach($user in $groupss.Users)
{
$sendemailto  =  $user.Email
$totalemail =  $sendemailto
  $emailgrouptoo+=$totalemail
 }
#You can also get this below information from Custom List also , in the article we are mainly showing how to send email to Owners Group Using PowerShell.
$smtpserver = "yourSMTP severname"
$emailfrm  =  "emailidfrom whom you have to send this email"
$Subject =  "We are sending email to Users"
$EmailBody  = "You type some information which you want to show in side the email body"
 send-mailmessage -smtpserver $smtpserver -from $emailfrm -to $emailgrouptoo  -subject $Subject -body $EmailBody

how to get the current item id for newly created item in SharePoint

In this article we can able to see how to get the current item id for newly created item, using REST API and JQuery.
 We are having a requirement to store the current item id in a Field, once we clicked on the custom save button.
We are having filed with name “RequestID” and couple of fields and having a custom button.
Call this function on “getNewRequestItemID” button click and use the below code.

<script type="text/javascript" src="/Dotnetsharepoint/SP2013/SiteAssets/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
$(function () {
 var listname = "YOURLISTNAME";
  });

function getNewRequestItemID(listname){
var currentitemid=0;
var siteURL = _spPageContextInfo.webAbsoluteUrl;
 var url = siteURL + "/_api/web/lists/getbytitle('" + listname + "')/items?$select=ID&$OrderBy=ID desc&$top=1";
$.ajax({
 url: url,
 method: "GET",
 async: false,
 headers: { "Accept": "application/json; odata=verbose" },
 success: function (data) {
    if(data.d.results.length>0){
        currentitemid = data.d.results[0].ID;
  $("input[title = 'RequestID']").val(currentitemid);
    }  
 },
 error: function (data) {      
 }
});
}
 </script>
 get the current item id for newly created item in SharePoint using javascript

Microsoft Flow Features



Create automated workflows between your favorite apps and services to get notifications, synchronize files, collect data, and more.
Flow app in SharePoint Office 365
Services:   
Now Microsoft Flow supporting 90 services. SharePoint, OneDrive for Business, Dynamics 365, OneDrive, SQL Server..Reference: https://flow.microsoft.com/en-us/services/             
New Features:
 Search by service
Users will be able to see all the triggers from a service by simply selecting that service. Also, once a trigger is selected, the same process can be done to add an action, as can be seen in the following screenshots.




Switch Case
It is an important addition to the already available nested conditionals support, and it "will make it very easy to have parallel branches of conditional logic based on a single value".
You can find switch by selecting the More … option after selecting New Step and then choosing Add a Switch Case. Inside a Switch Case you will select a value from the trigger or a previous step to switch on.
Office 365 and Outlook.com services
Trigger when an email is flagged – for example, you can now automatically create a task in Todoist (or Wunderlist) whenever you flag an email in Outlook
Flag an email as an action – create filters to flag emails – for example, automatically flag emails that come from your manager
Move an email to another folder – you can also automatically move emails between folders
Connect to Local or Network File Systems and Stripe
Flow can now connect to your Local File System or a Network File System. You can log or copy files from your own local Windows desktop PC to the cloud. Likewise, if you have a team Network Share, you can connect to that from Microsoft Flow.
Finally added four other Premium services: 



You can now use Stripe from Microsoft Flow. Stripe allows private individuals and businesses to accept payments over the internet. You can track customers, orders, invoices  and more. 

 Microsoft Flow integrates with Informix and DB2 so you can connect to resources stored in IBM Informix or IBM DB2 databases. We support SELECT, INSERT, UPDATE, and DELETE operations.

     UserVoice is a product management and customer support tool that allows businesses to build a suggestions portal for their users to submit feature ideas, build a ticketing system for customer support and build articles knowledge base for users.






Delete SharePoint list items based on particular view using PowerShell

In this article you can able to see how to delete  SharePoint list items based on the particular view and also having another condition how have to delete items on every Monday, we created a couple of views what type of data have to delete based on item created date.
One view is used to delete SharePoint list items every day and another delete only on Monday.

Note:  by default list item limit is 30 items, we have to modify the view based on the requirement I change to 5000 so every day it will delete only 5000 items to delete.

add-pssnapin microsoft.sharepoint.powershell
$web = get-spweb -identity "http://dotnetsharepoint.com/sites/sharepoint/deleteitems"
$MainList = $web.lists["DeleteListItems"];
$today = (get-date).DayOfWeek
if($today -eq "Monday")
{
$view = $MainList.Views["DeleteMondaylistitems"];
}   
else
{
$view = $MainList.Views["DeleteEverydaylistitems"];
}
$items = $MainList.GetItems($view)
$totalcount = $items.Count
$j = 0;
for($i = $totalcount -1; $i -ge 0; $i--)
{
$deleteitem = $items[$i]
write-host $deleteitem.ID
$deleteitem.Delete()
}

How to add blank value to choice field in SharePoint

As per my requirement I want to show blank value in choice field, but SharePoint won’t take space as a valid option. So we can use ASCII code.
Method1: We can use Unicode character that does not print nothing. I tried with U+205F & it’s working as expected. To use this character please check the below steps.
1.    Navigate to Start -> run -> charmap
  

It will open Character Map Window.
Choose Font: Calibri, Drag down the cursor & select black check the code finally click copy the code

Paste the code in choice field and save.

Now check blank field. 

It’s working as expected.
Method 2: Use ASCII code 0129. It is empty character that SharePoint will accept as a valid option. It will appears empty on dropdown list. Hold down the ALT key and type the number 0129

Flow app in SharePoint Office 365

Flow:    

We can create automated workflows between your favorite apps and services to get notifications, synchronize files, collect data, and more. See how it works. Introducing multiple environments — distinct spaces to store and manage your organization's flows.
Navigate to Office 365.
Office 365 new app Flow -> Click on Flow App                                                                     
                                                                
 Here we can create Flow in two ways

Create from blank

  We can choose our own template to create  flow.


Crete from template
   We can choose from existing template to create flow

Now we are going to create flow using Create from blank -> Click on create from blank


 Search for triggers and select, here we are selecting "Blogger when Post is created".


Add  Blog Id & Post Status
Here I selected my blog & Post status is All. It will get data from under all section in blog.
-> Click on New Step






-> Click Add an Action



       Search for triggers and select, here we are selecting "SharePoint Create item"
Enter SharePoint Site url & select list where you want to store blog                   details                                                                                                                                                         

Select the title on Dynamic Content -> Click on Create flow      
                                                                                                                              
Now Flow created successfully.



Now create a article in Blog & Publish. Finally check the SharePoint list what we selected in flow, Item was created successfully.         

Hope it's help.

Cannot connect to the server at this time. Changes to your data cannot be saved



  I Export to Excel SharePoint custom list, when I am trying to open that excel sheet it’s showing the below error.


Error:


Resolution:

I added the SharePoint site URL in Compatibility view.

Navigate to IE settings -> click on compatibility view settings.

 


Add SharePoint site url and close the settings.


Now refresh the page and check. Hope it will help.

SharePoint Online Real Time Training Contact: JLAKSHMITULASI@GMAIL.COM

Get Random values from SharePoint list using PowerShell

In this article we are going to learn how to Get Random SharePoint items using PowerShell.
PowerShell is a Powerful scripting language, we can do our work/tasks easily, having so many built-in commands are available in PowerShell. In that we are using Get-Random command to get the random SharePoint list items.




add-pssnapin microsoft.sharepoint.powershell
$web = get-spweb -identity "http://dotnetsharepoint.com /sites/sharepoint/getrandom "
$Employeelist = $web.lists["Employee"];
$listitemsTotal = $Employeelist.Items.Count
$getvalues = $Employeelist.Items
if($listitemsTotal -gt 0)
{
$Random=Get-Random -Count $listitemsTotal -InputObject(1..$listitemsTotal)
}
for($j=0;$j -lt $listitemsTotal;$j++){
$RandomVal=$Random[$j]
$EmpNameName=$getvalues[$RandomVal]["EmployeeId"];
Write-host $RandomVal
write-host $EmpNameName

}

Hide “Edit Links” in quick launch SharePoint 2013

Here you can see how to hide “Edit links” in quick launch left navigation in SharePoint 2013.
This option is useful to drag and drop links in the quick launch, but how ever having access to create a new item they can able to see this option and can also modify these options , we are hiding the Edit Links to restrict all the users, using the CSS  as shown below.
Add the Content Editor or Script Editor in the home page or in any page that you want to hide the “Edit Links”

<style>
.ms-displayInlineBlock
{
display: none;
}
</style>