Pages

Search This Blog

Showing posts with label Power Shell. Show all posts
Showing posts with label Power Shell. Show all posts

Saturday, March 29, 2014

Authentication issue from SharePoint Server using FQDN




If you are using a fully qualified domain name for your sharepoint site which is hosted on port 80 using domain or subdomain then you might not be able to access that site from the server itself. If you try to open the site then it will keep you prompting for user credentials again and again.
Now for that matter the problem lies in the resolution part of the domain name so you have to make any entry in backcoonectionhostnames to resolve the name to the local machine itself. 
You need to run this powershell command in your server which will make an entry in your registry and you will be good to go after that :-
New-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa\MSV1_0 -Name "BackConnectionHostNames" -Value "<your domain or subdomain name without http or https>" -PropertyType multistring

To update this property in future in case you have added some more domain names

Set-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa\MSV1_0 -Name "BackConnectionHostNames" -Value "<first domain or subdomain name>","<second domain or subdomain name>"

if you want to know the existing domain names in this property then retrieve by following command

Get-ItemProperty -Path HKLM:\System\CurrentControlSet\Control\Lsa\MSV1_0 

Do an IISRESET or application pool recycle to make apply these changes.

Saturday, March 23, 2013

Create Managed Path via PowerShell



#-----Function to Load SharePoint PowerShell Environment----#
function LoadSharePointPowerShellEnvironment
{
 write-host "Setting up PowerShell environment for SharePoint..." -foregroundcolor Yellow
 Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue
 write-host "SharePoint PowerShell Snapin loaded." -foregroundcolor Green
}



function Create-SPManagedPath
{
  param ($webApplicationUrl, $managedPathName)
  $managedPath = Get-SPManagedPath -WebApplication $webApplicationUrl -Identity $managedPathName -ErrorAction SilentlyContinue
  if ($managedPath -ne $null)
  {
  Write-Host "Managed path $managedPathName already exists."
  return
  }

  Write-Host "Creating managed path $managedPathName ..."
New-SPManagedPath –RelativeURL $managedPathName -WebApplication $webApplicationUrl
  Write-Host "Managed path $managedPathName created sucessfully" -foregroundcolor Green
}


LoadSharePointPowerShellEnvironment
Create-SPManagedPath "http://mywebappurl" "logical"

Friday, February 1, 2013

Download all solutions wsp from sharepoint 2010 central admin using powershell

[void][reflection.assembly]::LoadWithPartialName("Microsoft.SharePoint")
[void][reflection.assembly]::LoadWithPartialName("Microsoft.SharePoint.Administration")
[void][reflection.assembly]::LoadWithPartialName("System")
[void][reflection.assembly]::LoadWithPartialName("System.Collections")
[Microsoft.SharePoint.Administration.SPFarm]$farm = [Microsoft.SharePoint.Administration.SPFarm]::get_Local()

Write-Host -foregroundcolor White "Starting solutions download process..."

foreach ($solution in $farm.Solutions)
{
Write-Host -foregroundcolor White ""
Write-Host -foregroundcolor Yellow "Downloading solution $solution..."
$file = $solution.SolutionFile
$solutionName = $solution.name
$file.SaveAs("c:\solutions\$solutionName")
Write-Host -foregroundcolor Green "Solution $solutionName downloaded successfully."
}

Write-Host Write-Host -foregroundcolor Green "All solutions downloaded in c:\solutions folder"
Read-Host 'Done...'

Friday, January 4, 2013

Reset IIS on all the servers in FARM



Save the commands in a power shell script file and execute it in any of the servers present in FARM.



Write-Host -foregroundcolor Green "Restarting IIS on all the servers in FARM..."

[void][reflection.assembly]::LoadWithPartialName("Microsoft.SharePoint")
[void][reflection.assembly]::LoadWithPartialName("Microsoft.SharePoint.Administration")
[void][reflection.assembly]::LoadWithPartialName("System")
[void][reflection.assembly]::LoadWithPartialName("System.Collections")
# Get the local farm instance

[Microsoft.SharePoint.Administration.SPFarm]$farm = [Microsoft.SharePoint.Administration.SPFarm]::get_Local()

#Step through each server in the array and perform an IISRESET
#Also show IIS service status after the reset has completed

foreach ($server in $farm.Servers)
{
    if($server.Role -ne "Invalid")
    {
       Write-Host -foregroundcolor White ""
       Write-Host -foregroundcolor Yellow "Restarting IIS on server $server..."
       IISRESET $server.Name /noforce
       Write-Host -foregroundcolor Yellow "IIS status for server $server"
       IISRESET $server.Name /status
    }
}
Write-Host Write-Host -foregroundcolor Green IIS has been restarted on all servers
Read-Host 'Done...'



Tuesday, October 23, 2012

Attach Disposition Workflow on a content type using Powershell

Hi Friends,

Many times we are needed to attach a "Disposition Workflow" with a Content Type in SharePoint 2010. This is pretty easy to accoplish. Please find the PowerShell to do this.

# Method Calling
AddWorkflowToContentType $site $ContentTypeName "Disposition Approval" "WFA" $TaskListName

#Method Definition
function AddWorkflowToContentType($site, $ctName, $WfName, $WfAssociationName, $TaxTaskList)
   {
    [void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SharePoint')
    [void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.Office.Policy')

    [Guid]$wfTemplateId = New-Object Guid
    $web = $site.RootWeb
       $ct = $web.ContentTypes[$ctName]
       $culture = New-Object System.Globalization.CultureInfo("en-US")
       $template = $site.RootWeb.WorkflowTemplates.GetTemplateByName($WfName, $culture)
   
       if($template -ne $null)
       {                       
      $tasklist = $TaxTaskList
                     $historylist = "Workflow History"
                    
                        # Checking For WorkFlow History List; If not exists then create it
                        if(!$web.Lists[$historylist])
                        {
                            $web.Lists.Add($historylist, "A system library used to store workflow history information that is created in this site.  It is created by the Publishing feature.",
                            "WorkflowHistory", "00BFEA71-4EA5-48D4-A4AD-305CF7030140", 140, "100")
                           
       if (!$web.Features["00BFEA71-4EA5-48D4-A4AD-305CF7030140"]) {
                                Enable-SPFeature -Identity WorkflowHistoryList -Url $web.Url
                            }
    
                            $wfHistory = $web.Lists[$historylist]
                            $wfHistory.Hidden = $true
                            $wfHistory.Update()
                        }

                        # Checking For WorkFlow Task List; If not exists then create it
                        if(!$web.Lists[$tasklist])
                        {
                            $web.Lists.Add($tasklist, "This system library was created by the Publishing feature to store workflow tasks that are created in this site.", "WorkflowTasks", "00BFEA71-A83E-497E-9BA0-7A5C597D0107", 107, "100")
                        }
   
                        # Creating Workflow Association with Content Type
                        $association = [Microsoft.SharePoint.Workflow.SPWorkflowAssociation]::CreateSiteContentTypeAssociation($template, $WfAssociationName, $web.Lists[$tasklist], $web.Lists[$historylist])
                       
      $association.AllowManual = $false
                        #$association.AutoStartCreate = $true
                        $ct.AddWorkflowAssociation($association)
                        $ct.UpdateWorkflowAssociationsOnChildren($true, $true, $true, $false)
                        $association.Enabled=$true
                        $ct.Update()
                        $web.Update()
                        #$ct.WorkflowAssociations[0]           
       }
       else
       {
        Write-Error "Workflow Template not found"
                    Add-Content $logFileName "Workflow Template not found."
       }
   }

Happy Coding!!!

Prabhat

Saturday, March 31, 2012

Tired of viewing Correlation ID's searching in Log file under 14 hive

In this topic, i would like to cover how you can find out the error details in SharePoint without going into 14 hive and that big log file. There you are not sure what went wrong and you are not much intrested to find what was the issue.

Though, there are couple of 3rd party tools or freewares are available and you can very well use them but this small script will help you to identify the details with the help of the correlation id.

get-splogevent ?{$_.Correlation -eq ""} select Area, Category, Level, EventID, Message
Format-List

Change the GUID with the correlation ID you have got and that's it.

Friday, March 2, 2012

Configure BLOB cache for SharePoint


A BLOB cache is a disk-based cache that stores binary large objects (BLOBs) such as frequently used image, audio, and video files, and other files that are used to display Web pages. Each front-end Web server maintains its own BLOB cache. When you enable a BLOB cache, you specify the file types to include in the cache and also the location of the BLOB cache. The first time that a BLOB file is requested, the file is copied from the database to the BLOB cache on the front-end Web server. Future requests to the front-end Web server for that same file are then served from the file that is stored in the BLOB cache, instead of being served from the database. This reduces the network traffic and the load on the database server. (ref: http://technet.microsoft.com/en-us/library/gg277249.aspx)
The BLOB cache needs to specify in the web.config for each web application. By default, the BLOB caching is disabled in web.config. Open the web.config for the web application that you need to configure the BLOB cache. Normally you find the following line in the web.config of the web application:


<BlobCache location="C:\BlobCache\14" path="\.(gif|jpg|jpeg|jpe|jfif|bmp|dib|tif|tiff|ico|png|wdp|hdp|css|js|asf|avi|flv|m4v|mov|mp3|mp4|mpeg|mpg|rm|rmvb|wma|wmv)$" maxSize="10" enabled="false" />
You can modify the following attributes:
location – the path to the directory where the blob files stores in the disk.
path – specifies the condition for file names that will be included in the cache. By default SharePoint will include a regular expression that matches certain extensions. In most of the cases you just need to add/remove some extensions to the list.
maxSize – the maximum size for the cache expressed in GB, 10 GB is the default
enabled - specifies whether blob cache is enabled or not. True indicates enabled

Following points should also be kept in consideration with BLOB caching:
  • All front end web serves should have the BLOB caching enabled with same configuration
  • BLOB Caching works only for items in SharePoint libraries
  • Changes in CSS, JS etc., might not reflect immediately. If such a case occurs then the option is to flush the cache by navigating to the site collection's Site Settings. Select "Site Collection Object Cache" and then click "Force this server to reset its disk based cache."
  • You can also make use of the following PowerShell commands to flush the BLOB cache:
$webApp = Get-SPWebApplication "<WebApplicationURL>"
[Microsoft.SharePoint.Publishing.PublishingCache]::FlushBlobCache($webApp)
Write-Host "Flushed the BLOB cache for:" $webApp

Monday, February 6, 2012

Powershell script to retrieve a deployed wsp from configuration database : SharePoint 2010

Many a times, we find ourselves in a situation wherein we want to find out what are the contents of a deployed wsp so as to debug issues, compare releases etc.

This is not such a trivial task as the sharepoint central administration pages do not provide us with any option to retrieve a deployed wsp from the sharepoint configuration database.

This task can be done through a powershell script. The powershell script given below takes 2 parameters:

- The display name of the solution to retrieve (.wsp file)
- A path on the local machine where the retrieved wsp will be saved.

If no name of the solution is given , it displays the list of deployed solutions to the user and lets the user choose the solution to retrieve. Many more such scripts can be seen at the source project for this script available at http://sharepointpsscripts.codeplex.com/


param ([string] $name, [string] $localpath)
#Load the required SharePoint assemblies containing the classes used in the script
#The Out-Null cmdlet instructs the interpreter to not output anything to the interactive shell
#Otherwise information about each assembly being loaded would be displayed
[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0 , Culture=Neutral, PublicKeyToken=71e9bce111e9429c") | Out-Null

function Get-SolutionName()
{
    # Initialize an empty hashtable to store solution names and indexes
    $solHash = @{};
   
    # Bind to the collections of all solutions in the local farm and process them one by one, storing names in a hashtable
    # under automatically incremented indexes
    # The Foreach-Object cmdlet uses the begin/process/end structure to initialize the $i index counter
    ([Microsoft.SharePoint.Administration.SPFarm]::Local).Solutions |
        Foreach-Object {$i=1;} {$solHash.$i = $_.displayname; $i++} { }
   
    Write-Host;
   
    # If solutions were found, present the user with selection
    if ($solHash.Count -gt 0)
    {
        Write-Host -Object "The following solutions were found in the farm:" -ForegroundColor Green -BackgroundColor DarkMagenta;
        Write-Host;
       
        # Hashtables are not sortable, so in order to sort solutions by index keys have to be sorted separately first
        $solHash.Keys | Sort-Object | Foreach-Object {Write-Host -Object $("`t[{0}] {1}" -f $_, $solHash[$_]) -ForegroundColor Yellow -BackgroundColor DarkMagenta;}
        Write-Host;
        Write-Host -Object "Enter the index number of the solution you wish to retrieve, or 0 (zero) to exit: " -NoNewLine -ForegroundColor Green -BackgroundColor DarkMagenta;
       
        # Obtain input from user and return the matching value from the hashtable
        return $solHash[[int](Read-Host)];
    }
   
    # No solutions found in the configuration database
    else
    {
        Write-Host -Object "The local farm's solution store contains no solutions." -ForegroundColor Green -BackgroundColor DarkMagenta;
        Write-Host;
    }
}
# Check if name of target solution was specified as a parameter
if (-not $name)
{
    # Name of solution was not specifed, so call the Get-SolutionName function to obtain the name
    $name = Get-SolutionName;
   
    # If after calling the function the name is still unknown, stop execution
    if (-not $name)
    { break; }
}
# Check if local path to save the file to was specified as a parameter
if (-not $localpath)
{
    Write-Host;
    # Prompt and obtain local path value from user
    Write-Host -Object "Enter the local path to the folder you want the solution file to be saved to: " -ForegroundColor Green -BackgroundColor DarkMagenta;
    $localpath = Read-Host;
}
# Check if the path specified is valid and throw an exception if it's not
if (-not $(Test-Path -Path $localpath -PathType Container))
{
    throw "`"$localpath`" is not a valid path! If the path contains spaces, it must be enclosed in SINGLE quotes."
}
# Try to bind to the target solution
$solution = ([Microsoft.SharePoint.Administration.SPFarm]::Local).Solutions | Where-Object {$_.Name -eq $name}
Write-Host;
# Check if solution was found
if ($solution -ne $null)
{
    # Constitute the full local path (including file name)
    $solPath = Join-Path -Path $localpath -ChildPath $solution.SolutionFile.Name;
   
    # Try and save solution file locally
 $solution.SolutionFile.SaveAs($solPath);
   
    # If no errors occurred, display a success message
    if ($?)
    {
    Write-Host "Solution file saved successfully to $solPath" -ForegroundColor Green -BackgroundColor DarkMagenta;
       Write-Host;
    }
}
# Solution not found in the store; display a warning message
else
{
 Write-Host -Object "Solution `"$name`" could not be found!" -ForegroundColor Red -BackgroundColor DarkMagenta;
    Write-Host;
}

Tuesday, January 24, 2012

Setting the chunk size for downloading a file in Sharepoint 2010

Whenever you download a document from Sharepoint, Sharepoint puts the document in memory stream. There is a limit set as to how much data needs to be retrieved in a go if the document is heavy. This is controlled through chunk size.

Sharepoint default chunk size is set to 5MB, this means that if a client tries to open a document of 50MB and the chunk size is 5MB, the document is divided and retrieved in 10 chunks. Each chunk will be loaded into the memory of both the WFE handling the request and the SQL Server.

You can change the chunk size by executing following command using STSADM:

stsadm -o setproperty -pn large-file-chunk-size -pv 1073741824

This will set the chunk size to 1024 MB i.e. 1073741824 bytes.


Larger chunk size increases the performance, but adds more load on the WFE and SQL server as more data is loaded into the memory. So to set a desired chunk size, factors like number of users accesssing the site, system RAM, default file size that users are uploading to your system etc should be considered.

Saturday, January 21, 2012

Switch Application on Claim Authentication

If your application is currently configured with window authentication, and want to switch on claim, you can use below powershell commends for it.

$SPWebApp = Get-SPWebApplication "http://localhost"
$ SPWebApp.UseClaimsAuthentication = $True
$ SPWebApp.Update()
$webapp.ProvisionGlobally()
iisreset

Wednesday, January 18, 2012

Export SharePoint 2010 sites name to Excel file using Powershell


To get the SharePoint 2010 sites name in an Excel file using Powershell,

Go to SharePoint 2010 Management Shell, right click - Run as Administrator



And type the following command at the PowerShell prompt:
Get-SPSite | Get-SPWeb | Select url,title | Export-Csv


After that, this will ask for Path. Provide any physical drive name with file name (e.g.: C:\Sites.csv)

This will export all the sites name in excel file.

Thanks

Tuesday, January 17, 2012

Open PDF files directly in browser SharePoint 2010

Here is how you can tell SharePoint 2010 site to open the PDF files in the browser instead of prompting the user to save or open the PDF. This will be a great option to the most of end users. This needs simple Powershell scripting run on the server. Below is the code we should use:



# <# 
# .DESCRIPTION 
#  This script adds new MIME type to "AllowedInlineDownloadedMimeTypes" property list of defined SharePoint 2010 Web Application.
#
#  Script prompts you for MIME type and Web Application URL.
#
#  Code shall run in context of Farm Administrators group member.


If ( (Get-PSSnapin -Name "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null ) {
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
Get-SPWebApplication
$WebApp = Get-SPWebApplication $(Read-Host "Enter Web Application URL")
Write-Host "Mime Type Examples:""application/pdf, text/html, text/xml"


If ($WebApp.AllowedInlineDownloadedMimeTypes -notcontains ($MimeType = Read-Host "Enter a required mime type"))
{
  Write-Host -ForegroundColor White "Adding" $MimeType "MIME Type to defined Web Application"$WebApp.url
  $WebApp.AllowedInlineDownloadedMimeTypes.Add($MimeType)
  $WebApp.Update()
  Write-Host -ForegroundColor Green "The" $MimeType "MIME type has been successfully added."
} Else {
  Write-Host -ForegroundColor Red "The" $MimeType "MIME type has already been added."
}

Monday, January 16, 2012

How to change the default home page or Set Welcome Page of a SharePoint site using PowerShell Script - SharePoint 2010

By default a SharePoint 2010 publishing site uses default.aspx as its welcome page.
There are so many conditions where we use our custom web part page as the default page for our publishing site in place of general default.aspx. The best example for this is an application dashboard as the default page.

Below are four ways to set another page as your home page: (all four work for both 2007 and 2010)

1. From Site Settings (If the publishing features are enabled)
2. From SharePoint Designer
3. From code / API
4. From PowerShell

1. If the publishing features are enabled for a site then:
Go to Site Actions -> Site Settings -> Welcome Page
In SharePoint 2007

In SharePoint 2010

2. From SharePoint Designer:
Right-click the new page and click "Set as Home Page".
(For SharePoint 2007 this only appears to work from SharePoint Designer if the file is in the root of the site. I.e. the same place as default.aspx.)

3. From code / API:

using (SPSite oSiteCollection = new SPSite("http://sharepoint2010:2400"))
            {
                SPWeb oWebsite = oSiteCollection.OpenWeb();
                SPFolder oFolder = oWebsite.RootFolder;
                oFolder.WelcomePage = "SiteAssets/BecomeFan.aspx";
                oFolder.Update();
                oWebsite.Dispose();
            }

4. From PowerShell:
In SharePoint 2010, Create a powershell script file e.g. SetWelcomePage.ps1, with the following script:

Add-PsSnapin Microsoft.SharePoint.PowerShell
$assignment=Start-SPAssignment
$web=Get-SPWeb -Identity "http://sharepoint2010:2400" -AssignmentCollection $assignment
$rootFolder=$web.RootFolder
$rootFolder.WelcomePage="SiteAssets/BecomeFan.aspx"
$rootFolder.Update()
Stop-SPAssignment $assignment
$web.Update()
$web.Dispose()
Write-Host 'Welcome Page Set Successfully…'
Write-Host 'Press any key to exit…'
$x=$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
$Host.SetShouldExit(1)

After creating the script file, just run that file by right click and Run with PowerShell:


Now, navigate back to a site and see that the homepage is now set to the given page.


Monday, December 12, 2011

SharePoint 2010 FAST Search Server - Erase/Reset the content index and Clear the content collection

In SharePoint 2010 FAST Search, if you have crawled your site and after that you have deleted some documents. Again, you have full crawled your site, but the document you have deleted still show while search. Because the content index and content collection is not reset for these documents.

In SharePoint Server 2010 to reset the Content index, we need to follow following steps:

1. Open Central Administration and in the Application Management section, click Manage service applications.
2. On the Service Applications page, in the list of service applications, click your FAST Search Content SSA.



3. On the Search Administration page, under Crawling, click Index Reset.




4. On the Search Service Application: Index Reset page, click Reset Now. A confirmation dialog box appears; click OK to confirm the content index reset. The Search Service Application: Search Administration page opens and the System Status is displayed.

Before you start any new crawls, you must manually clear the content from the content collection your FAST Search Content Search Service Application was feeding to. The default collection name is sp.
Note - that clearing the content collection is irreversible.

Manually Clear the content collection:

1. On the Start menu, click All Programs, Click Microsoft FAST Search Server 2010 for SharePoint.






2. Click the Microsoft FAST Search Server 2010 for SharePoint shell.
3. At the Microsoft FAST Search Server 2010 for SharePoint shell command prompt, type the following command:
Clear-FASTSearchContentCollection -Name [collection name]
e.g.:
       Clear-FASTSearchContentCollection -Name sp






Wait for the command to finish. After successful completion, you content collection will be empty.

And after that, if you do Full Crawl, the the deleted documents will not be available.

Thanks.

Delete old versions of List Item via Poweshell SharePoint 2010


Most of the doucments were having lots of versions so the need was to remove all the existing versions except the latest version.


You can change this script to complete all the operation at one time means for all the libraries and lists under a web or all the site collections or all the web applications with in a farm.




The following script will remove all the existing versions of the documents except latest one.
PowerShell Command Prompt:


get-spWeb http://myweburl/
ForEach-Object {ForEach($_.list in $_.Lists){If($_.EnableVersioning -eq $True){if($_.Title -eq "ListName"){Write-host "List:"$_.Title "- List ID"$_.Id;$_.MajorVersionLimit = 1;$_.Update();ForEach($_.item in $_.items){$_.item.URL;$_.update()}}}}}




Note:
http://myweburl - Replace with your web URL
ListName - Replace with your list or library name
MajorVersionLimit = 1 - Change 1 to your specific limit

Friday, December 9, 2011

Enable Item Scheduling through code in SharePoint 2010


Many a times we need to create lists or sites from object model and hence it is often required to enable scheduling on list. Following code will do 3 things that are required to item scheduling:

  1. Enable Content approval
  2. Enable Versioning
  3. Enable Scheduling

Scheduling is dependent on both versions and content approval and should be enabled first.

Scheduling feature is only available in publishing site.


 using (SPSite site = new SPSite("http://sharepoint2010/"))
            {
                using (SPWeb web = site.RootWeb)
                {
                    SPList list=web.Lists["Documents"];
                    list.EnableModeration = true;
                    list.EnableMinorVersions = true;
                    list.Update();
                    Microsoft.SharePoint.Publishing.PublishingWeb.EnableScheduling(list);
                }
            }


list.EnableModeration = true; code will be actually doing the setting shown below:


list.EnableMinorVersions = true; this code will enable the minor versioning on the list as shown below:



Microsoft.SharePoint.Publishing.PublishingWeb.EnableScheduling(list); This code will actually enable scheduling on this list




To disable Scheduling in the list we can use following command:

Microsoft.SharePoint.Publishing.PublishingWeb.DisableScheduling(list);

###############################################################

We can also make use of powershell script for the same

$list= $SPList = Get-SPList -url "http://sharepoint2010/" -List Documents
$list.EnableModeration=$true
$list.EnableMinorVersions=$true
# To enable Scheduling in the list
[Microsoft.SharePoint.Publishing.PublishingWeb]::EnableScheduling($list)
# To disable Scheduling in the list
[Microsoft.SharePoint.Publishing.PublishingWeb]::DisableScheduling($list)


Wednesday, November 30, 2011

PowerShell Script - To Export data from XML file to SharePoint list

Requirement:
Export Data from XML file to SharePoint list - using PowerShell script
Steps:
1.    Open the Script.ps1 file in notepad and edit it.
2.    Change the location of the XML file (Data.Xml) in the #set up connection area.
3.    Change the Site URL in the #set up connection area.
4.    Change the web in the #set up connection area.
5.    Change the list name in the #set up list connections area.
6.    Go to Power shell command prompt and type the command à Path of the script.ps1 file à e.g. C:\script.ps1
7.    The functionality will be achieved.

Also here is the list template (.stp) for the required list (ProjectDetails.stp).
You can upload the template on your SharePoint site to create the list and then update the script.ps1 file accordingly so as to achieve the requirement.
*If the list field names are changed, then script.ps1 will be modified accordingly.
Cheers!