Saturday, October 10, 2020

Save an output using PowerShell

Most of the times we want to get some report or any such values from our SharePoint using PowerShell, Once we got the output in the PowerShell window, we want to save it as a document, for that we used to copy them and paste it in a new window. 

There is a simple solution for that, we can add a line of code to save the output data in the desired file format. 

Following is an example of code to get the SharePoint list field data as a output.

$site = Get-SPSite "https://mysharepointsite.com/"
$fID = "69xd368d-2f95-4juc-a1f9-8d4324ecb007"
$fields=$site.rootweb.fields | where ID -match $fID
$fields

We will be able to see the output in the PowerShell window now, to save it as output file as text document, please use the following code.

$site = Get-SPSite "https://project-insight.cas.com/"
$fID = "64cd368d-2f95-4bfc-a1f9-8d4324ecb007"
$fields=$site.rootweb.fields | where ID -match $fID
$fields >D:\Field_Details.txt

Now, the output is saved in the D drive automatically. As per the requirement we can change the directory and file format. 

No comments:

Post a Comment

How to create a SharePoint List in Tamil | SharePoint Online List in Tamil

  In this video i have given you a short overview on SharePoint List and different ways to create a list, How to create a SharePoint List in...