Total Pageviews

28 Nov 2018

Visual Studio Code: Black screen issue. Fix

If you are like me and you had an annoying issue with Visual Studio code that caused a black scree then you will like this fix.

My old fix:
code --disable-gpu

This was launching VS Code without GPU acceleration. It was a workable solution, but still very inconvenient.

New, permanent fix:
- Open your Nvidia Control panel
- Set Physx Configuration
- Under Select a physX processor select "CPU":




26 Jul 2018

Migrate MS Flow and PowerApps to a different Office 365 tenant. SharePoint Data Sources

Have you ever tried moving PowerApps or MS Flow from one Office 365 tenant to another? If you have SharePoint as a data source - then the only official way is to remove all such data sources and add them back. This PowerShell script will help you to automatically convert exported App packages to be compatible with the new tenant. This way you won't have to recreate SharePoint data sources.

Here is the script that will help you with this ordeal: https://github.com/Zerg00s/FlowPowerAppsMigrator




19 Jul 2018

Can PowerApps and MS Flow run with elevated privileges?

No, MS Flow and PowerApps are using current user's account.

Setup #1:
- User "Admin" creates a PowerApp that uses SharePoint List as a datasource
- User "Reader" gets Edit access to this app via Sharing, but this user has no permissions to the SharePoint list whatsoever.

What will happen?

Results:
- The "Reader" can open the PowerApp, but as soon as they try to create a new list item - they get an error:
There was a problem saving your change. The data source may be invalid.



Conclusion:
PowerApps use current user's permissions and don't have "run with elevated privileges" functionality.


Setup #2
- User "Admin" creates a PowerApp that uses SharePoint List as a data source
- User "Admin" creates a PowerApp button that runs an MS Flow that creates a list item in the SharePoint List
- User "Reader" gets Edit access to this app via Sharing, but this user has no permissions to the

Results:
- The "Reader" can open the PowerApp, but when they click on the button to run the flow that attempts to create a list item - nothing happens. In the MS flow history we see the 403 (Access denied) error:

System.UnauthorizedAccessException



Conclusion:
MS Flow that are run manually via a button in PowerApps use current user's permissions and don't have "run with elevated privileges" functionality.

P.S. MS Flows that are triggered on List Item Created / Updated are run using the credentials provided by the Flow author. So, depending on how the Flow was started - different credentials are used.




18 Jul 2018

SharePoint 2016 Restore User that was deleted from User Information List

There could be a scenario when the user was deleted both in AD and the User Information List and we need to restore it. That could be necessary when there was a custom solution developed that relies on the user accounts to exist in SharePoint. Needless to say these solutions were developed incorrectly, but who am I to judge.

For these rare cases, here is the way that to restore the deleted user. This worked for me in SharePoint 2016, but it might also work in 2013 and 2019.

Disclaimer: Any direct modifications to the SharePoint SQL databases are not supported by Microsoft. Restore the user by following approach only if you know for sure what you are doing.

1. First of all - determine an ID of the deleted user:


2. In SQL Management Studio - find your content database and navigate to the UserInfo table. Verify that deleted user is still listed in the table. Notice that tp_Deleted will equal to the user ID and tp_IsActive will be equal to 0:


3. Modify a row where tp_id is equal to the user's ID:
 a) set tp_Deleted to 0
 b) set tp_IsActive to True
 c) Save changes to the row


4. For the appropriate content database, run the following command to find deleted user in the  AllUserData table:
  
  SELECT * FROM [WSS_Content].[dbo].[AllUserData] 
  Where bit3 = 1 and tp_ID = User_ID

Make sure this command returned a single row. If there was a single row - proceed to restoring the user:

5. To restore the user, we need to change bit3 column's value from 1 to 0 :
 
 
 UPDATE [WSS_Content].[dbo].[AllUserData] 
 SET bit3 = 0 
 Where bit3 = 1 and tp_ID = User_ID


Done! Now go ahead and click on the deleted user. Verify that there is no error.

27 Jun 2018

Maintenance Mode in SharePoint Online and Modern pages

Turns out, if you append ?maintenancemode=true of your SharePoint page you will see a special maintenance view:



On your page, you will see a summary of data from the Manifest and Data tabs. The summary information includes:
Alias
The name of the web part
Id
The unique ID of the web part
Instance Id
The ID of a specific instance of a web part (that is, if you have two more of the same web parts on a page, they will each have the same web part ID, but a different instance ID.
IsInternal
Indicates whether the web part was made by Microsoft or a third party. If True, it is made by Microsoft. If False, it is made by a third party.
Version
The version number of the web part.
Environment
Environment: Indicates the SharePoint environment in use.
  • 0 = Test environment
  • 1 = Local Workbench
  • 2 = SharePoint
  • 3 = Classic SharePoint
UserAgent
A string that contains information about the device and software in use (such as browser type and version).


Microsoft article "Open and use the web part maintenance page"

SharePoint Online Performance. Easy Way to Capture Metrics

I've stumbled across an interesting Chrome Extension Page Diagnostics for SharePoint Chrome extension. It shows some useful info on the page performance.


Microsoft Article "Use the Page Diagnostics tool for SharePoint Online"



In my case SPRequestDuration and SPIISLatency were not displayed, but you can get these values by simply pressing F12 and typing g_iisLatency and/or g_duration in the console:
g_iisLatency - Shows network latency between the client browser and the IIS server
g_duration - Shows the time it took the page to be returned to the client browser



Update:
I've found out that g_iisLatency and g_duration only show up in the classic pages.




23 Jun 2018

Creating Forms for SharePoint Online using PowerApps, AngularJs, React or Nintex

Here my short presentation on the best options of creating forms in office 365, SharePoint Online

Disclaimer. I've made a couple of mistakes:
1. There is no mobile app for Microsoft Forms. But it MS Forms links open fine in any mobile browser. I guess there is no point in having the app in the first place.
2. The last app I've demonstrated was written using React+TypeScript, not AngularJs.

22 Jun 2018

Determine if SharePoint has enough memory allocated to the distributed cache service

After reading half a dozen articles explaining how to eyeball and calculate the distributed cache size I was wondering: Why no one suggests just to check the current consumption before changing anything? Here is a scary thought: What if we have a ton of memory and we don't need to add any more? I know, this sounds revolutionary.

This is a quick script that I've slapped together to show 1) maximum allocated memory for  the Distributed cache. 2) current usage for all AppFabric caches on the current server.

So, before bumping the Distributed cache, test the current consumption with the script below.


###### DETERMINE IF YOU HAVE ENOUGH MEMORY ALLOCATED TO DISTRIBUTED CACHE:
Add-PSSnapin Microsoft.SharePoint.Powershell
Use-CacheCluster
$hostname = hostname
$configuration = Get-AFCacheHostConfiguration -ComputerName $hostname -CachePort "22233"
Write-host Maximum Size: $($configuration.size)MB HostName: $($configuration.HostName) -ForegroundColor Blue
# Get-AFCache | % {Get-AFCacheConfiguration -CacheName $_.CacheName}
$caches = Get-AFCache | % {Get-AFCacheConfiguration -CacheName $_.CacheName}

 foreach($cache in $caches){
  $stats = Get-AFCacheStatistics $cache.CacheName
  Write-host $cache.CacheName -ForegroundColor Green Cache.
  Write-host Usage: $($stats.Size / 1MB) MB
  Write-host
 }

###### DETERMINE IF YOU HAVE ENOUGH MEMORY ALLOCATED TO DISTRIBUTED CACHE END

Here is the sample result:


20 Feb 2017

Hide .js and .js.map files when using TypeScript in Visual Studio Code

TypeScript is awesome, but what if I don’t want to see extra .js and .js.map files everywhere that are polluting your file explorer in Visual Studio Code?

Here is an easy solution:

- Open user settings:

image

- Add "files.exclude" property to the user settings or to the workspace settings:
"files.exclude": 
{       
    "**/*.js*": {"when": "$(basename).ts"},
    "**/*.js.map": true    
}

image

Done:

image

AngularJs + TypeScript with SharePoint


Getting intellisense in Visual Studio Code for AngularJs in TypeScript is not as straightforward as one would expect. Follow these steps below to get it working
image
Open Visual Studio Code
Press CTRL+` and run these commands:
tsc –init
npm install typings –global
typings install dt~jquery --global --save
image
typings install dt~angular
image
Now, if you run tsc compiler, your will get errors like so:
image
in order to fix it:
- create a global.d.ts file inside typings folder. It will be a new entry point for your TypeScript
- add import * as angular from "angular" as a first line
- add /// <reference path="index.d.ts" /> following that:
image
Modify tsconfig.json include "files" property to reference the new global.d.ts file: :
{
    "compilerOptions": {
        "target": "es5",
        "sourceMap": true
    },

    "files": [
    "typings/global.d.ts"
  ]
}
image

Let TypeScript compiler know which folder contains your .ts code by adding “include” property to the tsconfig.json file:
"include": ["src/*"]
where src/ is your source code folder image Run TypeScript compiler and start watching the files:
tsc --watch
image
Now you get angular and jQuery intellisense in TypeScript:
image
Well. it’s not really SharePoint specific, but it’s nice to know SharePoint developers can use the same steps.
If you are searching for a quick start with SharePoint and modern tools have a look at these articles by Andrew Koltyakov.

2 Nov 2016

Find Configuration Database Connection string in the Registry

SharePoint 2010:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\Secure\ConfigDb

SharePoint 2013:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\15.0\Secure\ConfigDb

pic

22 Oct 2016

The Best Way to Develop SharePoint Client Side Applications

 

Please, read these articles by Andrew Koltyakov.

He explains in great detail how to properly develop client side solutions using tools like node, gulp, Visual Studio Code with SharePoint

21 Oct 2016

Add jQuery to any page in a console

var script = document.createElement("script"); 
script.type="text/javascript"; 
script.src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"; 
document.getElementsByTagName('head')[0].appendChild(script);

11 Oct 2016

Stefan Goßner: PSCONFIGUI.EXE vs PSCONFIG.EXE

Nice article: Why I prefer PSCONFIGUI.EXE over PSCONFIG.EXE by Stefan Goßner

In case you need to use PSCONFIG.EXE to automate some tasks you should use the following command:

PSConfig.exe -cmd upgrade -inplace b2b -wait -cmd applicationcontent -install -cmd installfeatures -cmd secureresources -cmd services -install

7 Oct 2016

PowerShell script for monitoring SharePoint WFE's and SQL Server back-ends​​​​

#counters.txt contains a list of performance counters
#collect 
$fileName = "test{0:yyyyMMdd-HHmmss}.xml" -f (Get-Date) 
​get-counter -content (get-content counters.txt) -MaxSamples 2 -sampleinterval 5 |  Export-clixml $fileName

#save the results to the blg format. This will allow opening it with Performance Monitor
$fileName = "test{0:yyyyMMdd-HHmmss}.blg" -f (Get-Date) 
​get-counter -content (get-content counters.txt) -MaxSamples 2 -sampleinterval 5 |  Export-Counter $fileName
counters.txt contents:
\.NET CLR Memory(*)\% Time in GC 
\ASP.NET\Application Restarts 
\ASP.NET\Request Execution Time 
\ASP.NET\Requests Rejected 
\ASP.NET\Requests Queued 
\ASP.NET\Worker Process Restarts 
\ASP.NET\Request Wait Time 
\ASP.NET Applications(*)\Requests/Sec 
\LogicalDisk(*)\% Idle Time 
\Memory\Available MBytes 
\Memory\% Committed Bytes In Use 
\Memory\Page Faults/sec 
\Memory\Pages Input/sec 
\Memory\Page Reads/sec 
\Memory\Pages/sec 
\Memory\Pool Nonpaged Bytes 
\Network Interface(*)\Bytes Total/sec 
\Network Interface(*)\Packets/sec 
\Paging File(*)\% Usage 
\PhysicalDisk(*)\Current Disk Queue Length 
\PhysicalDisk(*)\% Disk Time 
\PhysicalDisk(*)\Disk Transfers/sec 
\PhysicalDisk(*)\Avg. Disk sec/Transfer 
\Process(*)\% Processor Time 
\Process(*)\Page Faults/sec 
\Process(*)\Page File Bytes Peak 
\Process(*)\Page File Bytes 
\Process(*)\Private Bytes 
\Process(*)\Virtual Bytes Peak 
\Process(*)\Virtual Bytes 
\Process(*)\Working Set Peak 
\Process(*)\Working Set 
\Processor(*)\% Processor Time 
\Processor(*)\Interrupts/sec 
\Redirector\Server Sessions Hung 
\Server\Work Item Shortages 
\System\Context Switches/sec 
\System\Processor Queue Length 
\Web Service(*)\Bytes Received/sec 
\Web Service(*)\Bytes Sent/sec 
\Web Service(*)\Total Connection Attempts (all instances) 
\Web Service(*)\Current Connections 
\Web Service(*)\Get Requests/sec

Show IIS Pool passwords in clear text

Windows 2012+ Solution:

Method #1


Add-WindowsFeature Web-WMI | Format-List
Get-CimInstance -Namespace root/MicrosoftIISv2 -ClassName IIsApplicationPoolSetting -Property Name, WAMUserName, WAMUserPass |
select Name, WAMUserName, WAMUserPass

 

Method #2


(Get-Item website).ProcessModel
(Get-Item website).ProcessModel.username
(Get-Item website).ProcessModel.password​

 

Windows 2008/R2 Solution


cd C:\Windows\system32\inetsrv
.\appcmd.exe list apppool /text:* ​

Add super user and super reader via PowerShell


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

####SET ACCOUNT NAMES (Replace Domain and UserName)
#SUPER USER ACCOUNT – Use your own Account (NB: NOT A SHAREPOINT ADMIN)
$sOrigUser= "domain\SP_SuperUser"
$sUserName = "SP_SuperUser"

#SUPER READER ACCOUNT – Use your own Account (NB: NOT A SHAREPOINT ADMIN)
$sOrigRead = "domain\SP_SuperRead"
$sReadName = "SP_SuperRead"

$apps = get-spwebapplication 
foreach ($app in $apps) {
   #DISPLAY THE URL IT IS BUSY WITH
   $app.Url
   if ($app.UseClaimsAuthentication -eq $true)
   {
    # IF CLAIMS THEN SET THE IDENTIFIER
    $sUser = "I:0#.w|" + $sOrigUser
    $sRead = "I:0#.w|" + $sOrigRead
   }
   else
   {
   # CLASSIC AUTH USED
     $sUser = $sOrigUser
     $sRead = $sOrigRead
   }
   
   # ADD THE SUPER USER ACC – FULL CONTROL (Required for writing the Cache)
   $policy = $app.Policies.Add($sUser, $sUserName)
   $policyRole = $app.PolicyRoles.GetSpecialRole([Microsoft.SharePoint.Administration.SPPolicyRoleType]::FullControl) 
   $policy.PolicyRoleBindings.Add($policyRole)

   $app.Properties["portalsuperuseraccount"] = $sUser
   $app.Update()

   # ADD THE SUPER READER ACC – READ ONLY
   $policy = $app.Policies.Add($sRead, $sReadName)
   $policyRole = $app.PolicyRoles.GetSpecialRole([Microsoft.SharePoint.Administration.SPPolicyRoleType]::FullRead) 
   $policy.PolicyRoleBindings.Add($policyRole)

   $app.Properties["portalsuperreaderaccount"] = $sRead
   $app.Update()
 }