Showing posts with label Project Server. Show all posts
Showing posts with label Project Server. Show all posts

Tuesday, July 28, 2020

Orphaned features in SharePoint Farm

Leave a Comment
While working for a client project and deploying existing SharePoint solution face issue about orphaned features which gives error a feature with feature id XXXXX already exist in farm.

There are two solution either in feature set force install option or delete orphaned features using following powershell commands:

Get-SPFeature | ? {$_.Scope -eq $null}


$feature = Get-SPFeature | ? {$_.DisplayName -eq "FeatureToBeDeleted"}

$feature.Delete()


Read More

Wednesday, June 3, 2020

PowerShell: Migrate SharePoint list content from one farm to other farm using CSOM

Leave a Comment
Scenario:
I met a scenario, where I need to migrate some list items (around 500+) from one farm (development) to another farm (Staging) and then to Production farm.

Ideal scenario probably would be to create list schema with content. However, in my current scenario I used CSOM for copying list items. Also in my scenario I just can't replace current content of destinate list item. I must have to just copy/move list items which are required for newly developed components.

Solution:

First I save list as list template along with content from source farm and create new list in destination farm using saved & imported list template definition. Then I delete list items which is not supposed to be copied. Although this can be skipped or cater through power shell script. However, due to quick delivery I wrote following power shell script which serve my purpose.

#Since I am doing for On-Premises, so I must have to import Client runtime for On-Premises
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

#Here I am getting user credentials
$siteURL="http://SomeSiteUrl/"
$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($siteURL)
$pwd=Read-Host -Prompt "Enter password" -AsSecureString
$creds=New-Object System.Net.NetworkCredential("domain\UserName",$pwd)
$ctx.Credentials=$creds

$sourceList=$ctx.Web.Lists.GetByTitle("[{ImportedListFromDestinationFarm}]")
$destList=$ctx.Web.Lists.GetByTitle("[{SourceListWhereDataNeedToCopied}]")
$sourceListItems=$sourceList.GetItems([Microsoft.SharePoint.Client.CamlQuery]::CreateAllItemsQuery())
$fields=$sourceList.Fields
$ctx.Load($sourceListItems)
$ctx.Load($sourceList)
$ctx.Load($destList)
$ctx.Load($fields)
$ctx.ExecuteQuery() 

#Here I am making sure, fields of list item isn't hiddent, or not readonly & don't have attachment
#and then updating in destination list
foreach($item in $sourceListItems)
 {
 #Write-Host $item.ID
$listItemInfo=New-Object Microsoft.SharePoint.Client.ListItemCreationInformation
$destItem=$destList.AddItem($listItemInfo)
foreach($field in $fields)
{
#Write-Host $field.InternalName "-" $field.ReadOnlyField
if((-Not($field.ReadOnlyField)) -and (-Not($field.Hidden)) -and ($field.InternalName -ne "Attachments") -and ($field.InternalName -ne "ContentType"))
{
#Write-Host $field.InternalName "-" $item[$field.InternalName]
$destItem[$field.InternalName]=$item[$field.InternalName]
$destItem.update()
} }}
$ctx.ExecuteQuery()
Read More

Saturday, November 24, 2018

PWA: EPM/Project Server site give administrator access to user or group for project web app

Leave a Comment
To give administrator access to user/group for project web app we need to run following powershell command
Grant-SPProjectAdministratorAccess -Url http://contoso-AppSrv/pwa -UserAccount contoso\john.woods
Read More

SharePoint 2013/2016: The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered

Leave a Comment
While trying to give administrator access to user for an instance of PWA I tried to run following command in sharepoint powershell:
Grant-SPProjectAdministratorAccess -url XXXX user domain\XXXX

I came across following issues:

SharePoint 2013/2016: The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered

Solution:
This happened b/c I tried to launch sharepoint powershell with user part of farm admin group, however I need to work with account similar access to sharepoint central admin app pool as that account requires right on server & databases to run configuration through powershell commands.
so I need to run following command throught account which I used to install my sharepoint farm:
Add-SPShellAdmin -UserName Domain\User



Read More

Sunday, January 21, 2018

PWA setting missing security settings

Leave a Comment
In project Server 2016, sharepoint permission mode is overriding project server PWA instance permission.

Scenario:

After configuring project server 2016 on sharepoint 2016 VM, I can't able to find security setting under PWA setting.

Solution:

Run following powershell command under SharePoint powershell (administrator-mode)

Set-SPProjectPermissionMode -url 'pwa site url' -mode ProjectServer
Read More

Wednesday, January 3, 2018

Disable or hide project server custom fields in project detail pages based on group current user belong too

Leave a Comment


Business Case:

Only PMO coordination team should able to update/set information related to project status. Currently project managers are updating project status which are affecting business validations & process flow.

Solution:
1.       Create a SharePoint group “PMO_Users”. Add PMO coordination team members to this group.
2.       Whenever a project is edited or created, at project details page, our custom module will verify if currently logged in user is part of “PMO_Users” group.
3.       If point (2) is true then project status button is enable and PMO coordination team can only able to update project status.
4.       Project managers can’t able to update project status (as they are not part of PMO_Users group.

Understanding:
This module works on the basis that project status (custom field) can’t be updated from Microsoft Project (client application) and only updateable from PWA.

Cross-Browser compatibility:
I have verified this module on chrome & internet explorer. 

Script/Code:

<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script>
ExecuteOrDelayUntilScriptLoaded(DisableProjectStatus,'sp.js');
function DisableProjectStatus()
{
var clientContext = new SP.ClientContext.get_current();
    var oWeb = clientContext.get_web();
    var currentUser = oWeb.get_currentUser();
    var allGroups = currentUser.get_groups();
    clientContext.load(allGroups);

    clientContext.executeQueryAsync(OnSuccess, OnFailure);

    function OnSuccess(sender, args)
    {
        var grpsEnumerator = allGroups.getEnumerator();
        var isNotPartOfPMO_Users=false;
        while(grpsEnumerator.moveNext())
        {          
            var group = grpsEnumerator.get_current();                  
            var grpTitle = group.get_title();
            if(grpTitle=='PMO_Users')
            {
                            isNotPartOfPCOAdmin=true;              
            }          
        }
        if(!isNotPartOfPMO_Users)
        {
            console.log('im not admin  user');
            var btnProjectStatus = $("button[id*='pfp_Repeater_ctl12_idCF_Btn_']");
            btnProjectStatus.attr("disabled", "disabled"); //similarly we can hide button as well.
        }
    }

    function OnFailure(sender, args)
    {
        console.log(args.get_message());
    }  
}
Read More

Monday, December 25, 2017

Powershell script to get folder and their filename in SharePoint, Project Server

Leave a Comment
I was asked for project documentation auditing to get listing of folders & files for all projects in Project Server 2016. Excercise is to make sure all project managers adhere to business check related to docuemntation must be provided for all project phases. So here is the script to do the magic

$folder = "\\SomePRojectserver\pwa\";
$toInclude =("Shared Documents");
$outputFolder="C:\TempOutput\output.csv";
gci -recurse -Path $folder | select parent,name,Directory |? { $_.Directory -match $toInclude }|
Export-Csv $outputFolder -Encoding UTF8
Read More

Run powershell script as domain user from non-domain computer

Leave a Comment
Recently I need to run one powershell script which will bring all files in EPM project folder for project documentation audit. Since I worked as consultant and mostly working on my personal laptop  at different client side. So I was struggling to run this powershell script

$folder = "\\SomePRojectserver\pwa\";
$toInclude =("Shared Documents");
$outputFolder="C:\TempOutput\output.csv";
gci -recurse -Path $folder | select parent,name,Directory |? { $_.Directory -match $toInclude }|
Export-Csv $outputFolder -Encoding UTF8

Reason is b/c powershell take my logged in user credentials either run powershell as administrator with elevated prvilages. So trick is to run following command either through cmd, powershell or through run command:

.\runas.exe /netonly /user:domain\username powershell.exe
Read More

Tuesday, December 19, 2017

Power BI / Excel: OData feed Dataformat error "The given URL neither points to an OData service or a feed"

Leave a Comment
Scenario:
While updating some of columns in Power BI / Excel I started facing following error:

DataFormat.Error: OData&colon; The given URL neither points to an OData service or a feed:"http://SomeEPMServer/pwa/_api/Projectdata/Projects". Although if you tried same rest api/odata feed in browser it fetch related project feed.

Causes:
 Somehow my credentials for data source which I set to used as current user credentials has not been working.

Solution:
Delete current set up credentials from Datasource settings-> Edit permission and update it to be used as current windows account at organizational level.
Read More

Project server: reserve keyword custom field odata feed

Leave a Comment
Issue: Odata error processing request:



We should not use reserve keyword while creating custom fields for project server (2010/2013/2016). What I faced while using Power BI through OData feed was facing conflict of my custom field with reserve keyword.
Cause: Duplicate custom field
There was a field called "Project ID" but this custom field internal name become "projectid" which is reserve internal field use by Project server for referencing different projects

Solution: 
Just rename custom field "Project ID" to "Internal Project ID" and it solve the issue.



 
Read More