Blogs about sharepoint ,Sharepoint Designer,Infopath and powershell
SharePoint Online Get all user Permissions. Permission Matrix.
SharePoint Online Permission Matrix
Hi After migration you may like to compare the existing user permissions(On-Prem and current user permission (Online)
Note : NTAuthenitcated users need to be replaced with Every one .
Please use the below two Powers-hell script to get the result
Pre requisites :
1. Sharepoint online management shell
2.Download the Sharepoint SDK , It will install all the SharePoint client related Dll
3. Have admin permission
Paths to SDK. Please verify location on your computer.
# On farm it would be available at c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\
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"
Two set power shell required to get the result
1.
please the name it as powershellUserpermission.ps1 (as per u r wish)
--- Begin
Import-Module Microsoft.Online.SharePoint.PowerShell
$admin = "your email id "
$pass = ConvertTo-SecureString "Pwad" -AsPlainText -Force
$OutputFile = "C:\Temp\Company_AllSitePermissions.csv"
Set-Content $OutputFile "Site,HasUniquePerm?,Group Name,Group Owner,Login Name,Roles"
Function Get-SPOAllSitePermissions ($url)
{
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($url)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($admin, $pass)
$web = $ctx.Web
Load-CSOMProperties -Object $web -PropertyNames @("HasUniqueRoleAssignments", "Url", "Title")
$ctx.Load($ctx.Web.Webs)
$ctx.Load($ctx.Web.RoleAssignments)
$ctx.ExecuteQuery()
Write-Host $web.Url
$webUrl = $web.Url
$record = "`"$webUrl`",$($web.HasUniqueRoleAssignments),"
if($web.HasUniqueRoleAssignments -eq $true) {
$firstIteration = $true #helps when to append commas
foreach($roleAssignment in $ctx.Web.RoleAssignments) {
Load-CSOMProperties -Object $roleAssignment -PropertyNames @("Member","RoleDefinitionBindings")
$ctx.ExecuteQuery()
$roles = ($roleAssignment.RoleDefinitionBindings | Select -ExpandProperty Name) -join ", ";
$loginName = if($roleAssignment.Member.PrincipalType -eq "User") { $($roleAssignment.Member.LoginName) } else { "" }
$record += if($firstIteration) { "" } else { ",," }
$record += "`"$($roleAssignment.Member.Title)`",`"$($roleAssignment.Member.OwnerTitle)`","
$record += "`"$loginName`",`"$roles`""
Add-Content $OutputFile $record
$firstIteration = $false
$record = ""
}
}
else {
Add-Content $OutputFile $record #you can refer the permissions from its parent web.
}
if($web.Webs.Count -eq 0)
{
}
else {
foreach ($web in $web.Webs) {
Get-SPOAllSitePermissions -Url $web.Url
}
}
}
# Paths to SDK. Please verify location on your computer.
# On farm it would be available at c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\
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"
.\Load-CSOMProperties.ps1
Get-SPOAllSitePermissions "https://Tenant/site-collection" ///--- Url.. Subsite or site-collection
$admin = "your email id "
$pass = ConvertTo-SecureString "Pwad" -AsPlainText -Force
$OutputFile = "C:\Temp\Company_AllSitePermissions.csv"
Set-Content $OutputFile "Site,HasUniquePerm?,Group Name,Group Owner,Login Name,Roles"
Function Get-SPOAllSitePermissions ($url)
{
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($url)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($admin, $pass)
$web = $ctx.Web
Load-CSOMProperties -Object $web -PropertyNames @("HasUniqueRoleAssignments", "Url", "Title")
$ctx.Load($ctx.Web.Webs)
$ctx.Load($ctx.Web.RoleAssignments)
$ctx.ExecuteQuery()
Write-Host $web.Url
$webUrl = $web.Url
$record = "`"$webUrl`",$($web.HasUniqueRoleAssignments),"
if($web.HasUniqueRoleAssignments -eq $true) {
$firstIteration = $true #helps when to append commas
foreach($roleAssignment in $ctx.Web.RoleAssignments) {
Load-CSOMProperties -Object $roleAssignment -PropertyNames @("Member","RoleDefinitionBindings")
$ctx.ExecuteQuery()
$roles = ($roleAssignment.RoleDefinitionBindings | Select -ExpandProperty Name) -join ", ";
$loginName = if($roleAssignment.Member.PrincipalType -eq "User") { $($roleAssignment.Member.LoginName) } else { "" }
$record += if($firstIteration) { "" } else { ",," }
$record += "`"$($roleAssignment.Member.Title)`",`"$($roleAssignment.Member.OwnerTitle)`","
$record += "`"$loginName`",`"$roles`""
Add-Content $OutputFile $record
$firstIteration = $false
$record = ""
}
}
else {
Add-Content $OutputFile $record #you can refer the permissions from its parent web.
}
if($web.Webs.Count -eq 0)
{
}
else {
foreach ($web in $web.Webs) {
Get-SPOAllSitePermissions -Url $web.Url
}
}
}
# Paths to SDK. Please verify location on your computer.
# On farm it would be available at c:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\
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"
.\Load-CSOMProperties.ps1
Get-SPOAllSitePermissions "https://Tenant/site-collection" ///--- Url.. Subsite or site-collection
2. Second Powershell
please the name it as Load-CSOMProperties.ps1 (don't change the name)
-- Begin
<#
.Synopsis
Facilitates the loading of specific properties of a Microsoft.SharePoint.Client.ClientObject object or Microsoft.SharePoint.Client.ClientObjectCollection object.
.DESCRIPTION
Replicates what you would do with a lambda expression in C#.
For example, "ctx.Load(list, l => list.Title, l => list.Id)" becomes
"Load-CSOMProperties -object $list -propertyNames @('Title', 'Id')".
.EXAMPLE
Load-CSOMProperties -parentObject $web -collectionObject $web.Fields -propertyNames @("InternalName", "Id") -parentPropertyName "Fields" -executeQuery
$web.Fields | select InternalName, Id
.EXAMPLE
Load-CSOMProperties -object $web -propertyNames @("Title", "Url", "AllProperties") -executeQuery
$web | select Title, Url, AllProperties
#>
function global:Load-CSOMProperties {
[CmdletBinding(DefaultParameterSetName='ClientObject')]
param (
# The Microsoft.SharePoint.Client.ClientObject to populate.
[Parameter(Mandatory = $true, ValueFromPipeline = $true, Position = 0, ParameterSetName = "ClientObject")]
[Microsoft.SharePoint.Client.ClientObject]
$object,
# The Microsoft.SharePoint.Client.ClientObject that contains the collection object.
[Parameter(Mandatory = $true, ValueFromPipeline = $true, Position = 0, ParameterSetName = "ClientObjectCollection")]
[Microsoft.SharePoint.Client.ClientObject]
$parentObject,
# The Microsoft.SharePoint.Client.ClientObjectCollection to populate.
[Parameter(Mandatory = $true, ValueFromPipeline = $true, Position = 1, ParameterSetName = "ClientObjectCollection")]
[Microsoft.SharePoint.Client.ClientObjectCollection]
$collectionObject,
# The object properties to populate
[Parameter(Mandatory = $true, Position = 1, ParameterSetName = "ClientObject")]
[Parameter(Mandatory = $true, Position = 2, ParameterSetName = "ClientObjectCollection")]
[string[]]
$propertyNames,
# The parent object's property name corresponding to the collection object to retrieve (this is required to build the correct lamda expression).
[Parameter(Mandatory = $true, Position = 3, ParameterSetName = "ClientObjectCollection")]
[string]
$parentPropertyName,
# If specified, execute the ClientContext.ExecuteQuery() method.
[Parameter(Mandatory = $false, Position = 4)]
[switch]
$executeQuery
)
begin { }
process {
if ($PsCmdlet.ParameterSetName -eq "ClientObject") {
$type = $object.GetType()
} else {
$type = $collectionObject.GetType()
if ($collectionObject -is [Microsoft.SharePoint.Client.ClientObjectCollection]) {
$type = $collectionObject.GetType().BaseType.GenericTypeArguments[0]
}
}
$exprType = [System.Linq.Expressions.Expression]
$parameterExprType = [System.Linq.Expressions.ParameterExpression].MakeArrayType()
$lambdaMethod = $exprType.GetMethods() | ? { $_.Name -eq "Lambda" -and $_.IsGenericMethod -and $_.GetParameters().Length -eq 2 -and $_.GetParameters()[1].ParameterType -eq $parameterExprType }
$lambdaMethodGeneric = Invoke-Expression "`$lambdaMethod.MakeGenericMethod([System.Func``2[$($type.FullName),System.Object]])"
$expressions = @()
foreach ($propertyName in $propertyNames) {
$param1 = [System.Linq.Expressions.Expression]::Parameter($type, "p")
try {
$name1 = [System.Linq.Expressions.Expression]::Property($param1, $propertyName)
} catch {
Write-Error "Instance property '$propertyName' is not defined for type $type"
return
}
$body1 = [System.Linq.Expressions.Expression]::Convert($name1, [System.Object])
$expression1 = $lambdaMethodGeneric.Invoke($null, [System.Object[]] @($body1, [System.Linq.Expressions.ParameterExpression[]] @($param1)))
if ($collectionObject -ne $null) {
$expression1 = [System.Linq.Expressions.Expression]::Quote($expression1)
}
$expressions += @($expression1)
}
if ($PsCmdlet.ParameterSetName -eq "ClientObject") {
$object.Context.Load($object, $expressions)
if ($executeQuery) { $object.Context.ExecuteQuery() }
} else {
$newArrayInitParam1 = Invoke-Expression "[System.Linq.Expressions.Expression``1[System.Func````2[$($type.FullName),System.Object]]]"
$newArrayInit = [System.Linq.Expressions.Expression]::NewArrayInit($newArrayInitParam1, $expressions)
$collectionParam = [System.Linq.Expressions.Expression]::Parameter($parentObject.GetType(), "cp")
$collectionProperty = [System.Linq.Expressions.Expression]::Property($collectionParam, $parentPropertyName)
$expressionArray = @($collectionProperty, $newArrayInit)
$includeMethod = [Microsoft.SharePoint.Client.ClientObjectQueryableExtension].GetMethod("Include")
$includeMethodGeneric = Invoke-Expression "`$includeMethod.MakeGenericMethod([$($type.FullName)])"
$lambdaMethodGeneric2 = Invoke-Expression "`$lambdaMethod.MakeGenericMethod([System.Func``2[$($parentObject.GetType().FullName),System.Object]])"
$callMethod = [System.Linq.Expressions.Expression]::Call($null, $includeMethodGeneric, $expressionArray)
$expression2 = $lambdaMethodGeneric2.Invoke($null, @($callMethod, [System.Linq.Expressions.ParameterExpression[]] @($collectionParam)))
$parentObject.Context.Load($parentObject, $expression2)
if ($executeQuery) { $parentObject.Context.ExecuteQuery() }
}
}
end { }
}
---End
Sharepoint online - Configure/ setup Email enable document library or list
SharePoint online migration/Setup on Email enable list/Document library..
Those who migrated the SharePoint on per-misses(2010/13..) to SharePoint online might have come across the limitation of how to setup email enabled list/document library in SharePoint online.
Here is the work around, I have setup using Flow, Shared Eamilbox ids and alias. If we have any query please leave your comments I will help you.
Here is the link that demonstrates how to do this:
Thanks
Sharepoint Practice Head.
Deva
How To Check Whether The List/Library Item Is A File Or A List Folder In SharePoint Online Using Online PowerShell script
Below code help to identify the SharePoint Online list/library (all) items folder and file. Based on that you can delete the file or folder. If you want generate the inventory of the list/ library you can use this code. (Change the list template Id or name)
Prerequisites
- Download SharePoint online Management Shell and Install
- Enable the execution policy true (Check DOS command..
- Copy the below code and create XX.ps1 file and execute it Online Management Shell.
- You Should have Tenant admin permission
Powershell code to generate folder and file item in a SharePoint online list/library
#Copy start here
--------------------------------------------------------------
function Get-SPOWeb()
{
param (
$SPOCredentials,
$Url,
$IncludeSubsites=$false
)
write-host "Inside spoweb" -foregroundcolor green
$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$ctx.Credentials = $SPOCredentials
$ctx.Load($ctx.Web)
$ctx.Load($ctx.Web.lists)
$ctx.Load($ctx.Web.Webs)
$ctx.ExecuteQuery()
write-host "Inside spoweb - Before for each loop " -foregroundcolor green
Write-Host "(Lists count: "$ctx.Web.lists.count")"
foreach($list in $ctx.Web.lists)
{
try{
#.. write out every document library which is not the standard "Site Assets"
# if(($list.BaseTemplate -eq 101) -and ($list.Title -ne "Site Assets") -and ($list.Title -eq "TestLibrary100"))
#if document library use the below if
# if(($list.BaseTemplate -eq 101)
#If coustom library use the below if Replace the TestLibrary name with your custom library
if($list.Title -eq "TestLibrary")
{
Write-Host "Web:" $ctx.Web.Url -foregroundcolor green
Write-Host "ListTitle:" $list.Title -foregroundcolor green
#Write-Host "BaseTemplate:" $list.BaseTemplate -foregroundcolor green
$camlQuery = New-Object Microsoft.SharePoint.Client.CamlQuery
#Retrive all list item with filter <Gt> replace based on your requirements
$camlQuery.ViewXml ="<View Scope='RecursiveAll'><Query><OrderBy><FieldRef Name='Modified'/></OrderBy><Where><Gt><FieldRef Name='Modified' /><Value IncludeTimeValue='TRUE' Type='DateTime'>2013-01-01T11:34:54Z</Value></Gt></Where></Query></View>"
$allItems=$list.GetItems($camlQuery)
$ctx.Load($allItems)
$ctx.ExecuteQuery()
Write-Host "ExecuteQuery passs"
$Itemscount=$allItems.count
Write-Host "List items count:" $Itemscount
$fileref=''
$itemexit=$false
$itemcounter=0
if ($Itemscount-gt0)
{
for ($i=$Itemscount-1; $i-ge0; $i--)
{
$item=$allItems[$i];
$fileref=$item["FileRef"]
$siteInfos = $itemStructure | Select-Object *;
Write-Host "Fileref" $fileref
Write-Host "SiteURL" $ctx.Web.Url
Write-Host "Modified" $item["Modified"]
Write-Host "FSObjType" $item["FSObjType"]
$siteInfos.File=$fileref
$siteInfos.SiteURL=$ctx.Web.Url
$siteInfos.Modified=$item["Modified"]
$siteInfos.Modified=$item["FSObjType"]
$global:sitesList += $siteInfos
# FSObject type data 0 means item is file and 1 means folder. based on that you can generate the result and delete files or folder
# t
if ($item["FSObjType"] ==0)
{
$allItems[$i].DeleteObject()
$itemexit=$true
$itemcounter=$itemcounter+1
}
}
#Execute only when items found
if($itemexit)
{
$ctx.ExecuteQuery()
Write-Host "Files Deleted succesfully"
}
}
}
}
catch{
Write-Host "Error while reading list:" $list.Title "$($_.Exception.Message)" -foregroundcolor red
}
}
if($ctx.Web.Webs.Count -gt 0 -and $IncludeSubsites)
{
Write-Host "--" -ForegroundColor DarkGreen
for($i=0;$i -lt $ctx.Web.Webs.Count ;$i++)
{
write-host $ctx.Web.Webs[$i].Url
Get-SPOWeb -SPOCredentials $SPOCredentials -Url $ctx.Web.Webs[$i].Url -IncludeSubsites $IncludeSubsites
}
}
}
Import-Module Microsoft.Online.SharePoint.PowerShell
#Replce with your sharepoint Online admin URL not a site URL
# You need to have admin access in the tenant else it wont work
$adminUrl = "https://#######.sharepoint.com"
#Replace your user name
$userName = "############"
$password = Read-Host "Please enter the password for $($userName)" -AsSecureString
$credentials = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $password
$SPOCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $password)
Connect-SPOService -Url $adminUrl -Credential $credentials
write-host "Info: Connected succesfully to Office 365" -foregroundcolor green
# Local variables
$global:sitesList = @()
$delimiter=","
# Build structure what are the fields you want pls update List/library columns
$itemStructure = New-Object psobject
$itemStructure | Add-Member -MemberType NoteProperty -Name "File" -value ""
$itemStructure | Add-Member -MemberType NoteProperty -Name "Modified" -value ""
$itemStructure | Add-Member -MemberType NoteProperty -Name "FSObjType" -value ""
$itemStructure | Add-Member -MemberType NoteProperty -Name "SiteURL" -value ""
write-host "SPOWeb-Start"
# give your site collection url-- Get-SPOWeb -SPOCredentials $SPOCredentials -Url "https://##########/xyz" -IncludeSubsites $true
try{
#File creation
$guid=[guid]::NewGuid()
$listfilepath="H:\PowershellResults\Documentlist_"+$guid+".csv"
$sitesList | Where-Object {$_} | Export-Csv -Delimiter "$delimiter" -Path $listfilepath -notype
#####
write-host "Excel file created in this location:" $listfilepath -ForegroundColor Green
}
catch{
write-host "Excel file not created. Please check file path and try again." -ForegroundColor Red
}
# Copy End Here
-----------
Nintex SharePoint Online Approval Process not supporting Lazy approval process
Team,
SharePoint Online Migration Check List
Currently I am involving in a major SharePoint Migration project from SharePoint 2010 to SharePoint online.
Most of the existing Business process contains (workflow) approval process in different levels. Such as approval from Manager,admin and finally service desk. But in Nintex SharePoint online version won't support the Lazy approval fully.
Means You can't get the Approver name and Approver Comments. If you used a AD group in approval process, the task list will be updated with Group name and Modified Name will be updated with "Sharepoint APP" You can't get the Approver name and comments.
Nintex keep on telling some workaround, but in real time we are not able to achieve it
Before buying the Nintex tool please consider this factor for migration.
You can get the Approver name and comments using office 365 flow.
hope the above information useful to you. if you like please share your comments.
If you find any other alternative please share.
Thanks
Devarajan SM (Deva)
SharePoint Architect.
Subscribe to:
Posts (Atom)
SPFX - HTTPClient - Curd Operations - SharePoint list.
Create solution in the name of SpfxCrud. ISpfxCrudProps.ts export interface ISpfxCrudProps { description : string ; context : an...
-
$now = (Get-Date).AddDays(-1); $lastrun_converted = [microsoft.sharepoint.utilities.sputility]::CreateISO8601DateTimeFromSystemDateTime($...
-
<# The below PowerShell script enumerates through all sites with unique permissions and fetches users with Full Control Permission gran...
-
<Sharepoint:SPSecurityTrimmedControl runat="server" Permissions="ManageLists"> add the above code beofre ribbo...