Search/Identify blocked file types in SharePoint

In SharePoint 2016 On-Prem, Microsoft has reduced the number of blocked file types from previous versions of SharePoint. It is totally different than the SharePoint 2010 / 2013. In SharePoint 2013, there are 105 default file types that are blocked by default but in SharePoint 2016, this number goes all the way down to 6. Interestingly, there is no blocked file type in SharePoint Online.

Self-Note:

Block type references:

Small Script to find all blocked file types:

$path = "C:\DRIVERS";
$extensitons = @("*.ade","*.adp","*.asa","*.ashx","*.asmx","*.asp","*.bas","*.bat","*.cdx","*.cer",`
                "*.chm","*.class","*.cmd","*.cnt","*.com","*.config","*.cpl","*.crt","*.csh","*.der",`
                "*.dll","*.exe","*.fxp","*.gadget","*.grp","*.hlp","*.hpj","*.hta","*.htr","*.htw","*.ida",`
                "*.idc","*.idq","*.ins","*.isp","*.its","*.jse","*.json","*.ksh","*.lnk","*.mad","*.maf","*.mag",`
                "*.mam","*.maq","*.mar","*.mas","*.mat","*.mau","*.mav","*.maw","*.mcf","*.mda","*.mdb",`
                "*.mde","*.mdt","*.mdw","*.mdz","*.ms-one-stub","*.msc","*.msh","*.msh1","*.msh1xml",`
                "*.msh2","*.msh2xml","*.mshxml","*.msi","*.msp","*.mst","*.ops","*.pcd","*.pif","*.pl",`
                "*.prf","*.prg","*.printer","*.ps1","*.ps1xml","*.ps2","*.ps2xml","*.psc1","*.psc2","*.pst",`
                "*.reg","*.rem","*.scf","*.scr","*.sct","*.shb","*.shs","*.shtm","*.shtml","*.soap",`
                "*.stm","*.svc","*.url","*.vb","*.vbe","*.vbs","*.vsix","*.ws","*.wsc","*.wsf","*.wsh","*.xamlx");

Get-Childitem -r -path $path\* -include $extensitons | %{$_.fullname}

#Optionally push results to a text file
#Get-Childitem -r -path $path\* -include $extensions | %{$_.fullname} > C:\File_Extensions.txt

image

Fleanser – improves our productivity in migrating file shares to SharePoint Online

HuonIT excels in File Share migration projects with the introduction of custom developed cleansing and mirroring tool. Internally named Fleanser v1.0.

Our tool replaces part of the functionality provided by ShareGate solutions in migrating file share to SharePoint online environment.

Fleanser runs, various analytic operations in file paths to cleanse and shorten them intelligently when required. It also generates various analytic reports during cleanse process to back track on action applied against each file/folder members.

We tested our first version of this tool (functional edition) today for a client and we immediately saw the value we could add to our customers.

Proud to be a creator of this tool. We have already planned to add more functionalities to this tool in the subsequent releases.

Untitled-3

Office 365/SharePoint Online – OneDrive File Migration

Currently I am in the process of migrating a file share to SharePoint online libraries. One of the pre-check that I need to run before synchronizing the files is to make sure that these files/folders don’t have illegal characters defined by SharePoint online requirement.

The script below

function Check-IllegalCharacters ($Path, [switch]$Fix, [switch]$Verbose) { Write-Host Checking files in $Path, please wait... #Get all files and folders under the path specified $items = Get-ChildItem -Path $Path -Recurse foreach ($item in $items) { #Check if the item is a file or a folder if ($item.PSIsContainer) { $type = "Folder" } else { $type = "File" } #Report item has been found if verbose mode is selected if ($Verbose) { Write-Host Found a $type called $item.FullName } #Check if item name is 128 characters or more in length if ($item.Name.Length -gt 127) { Write-Host $type $item.Name is 128 characters or over and will need to be truncated -ForegroundColor Red } else { $illegalChars = '[&{}~#%]' filter Matches($illegalChars) { $item.Name | Select-String -AllMatches $illegalChars | Select-Object -ExpandProperty Matches Select-Object -ExpandProperty Values } #Replace illegal characters with legal characters where found $newFileName = $item.Name Matches $illegalChars | ForEach-Object { Write-Host $type $item.FullName has the illegal character $_.Value -ForegroundColor Red #These characters may be used on the file system but not SharePoint if ($_.Value -match "&") { $newFileName = ($newFileName -replace "&", "and") } if ($_.Value -match "{") { $newFileName = ($newFileName -replace "{", "(") } if ($_.Value -match "}") { $newFileName = ($newFileName -replace "}", ")") } if ($_.Value -match "~") { $newFileName = ($newFileName -replace "~", "-") } if ($_.Value -match "#") { $newFileName = ($newFileName -replace "#", "") } if ($_.Value -match "%") { $newFileName = ($newFileName -replace "%", "") } } #Check for start, end and double periods if ($newFileName.StartsWith(".")) { Write-Host $type $item.FullName starts with a period -ForegroundColor red } while ($newFileName.StartsWith(".")) { $newFileName = $newFileName.TrimStart(".") } if ($newFileName.EndsWith(".")) { Write-Host $type $item.FullName ends with a period -ForegroundColor Red } while ($newFileName.EndsWith(".")) { $newFileName = $newFileName.TrimEnd(".") } if ($newFileName.Contains("..")) { Write-Host $type $item.FullName contains double periods -ForegroundColor red } while ($newFileName.Contains("..")) { $newFileName = $newFileName.Replace("..", ".") } #Fix file and folder names if found and the Fix switch is specified if (($newFileName -ne $item.Name) -and ($Fix)) { Rename-Item $item.FullName -NewName ($newFileName) Write-Host $type $item.Name has been changed to $newFileName -ForegroundColor Blue } } } } $ErrorActionPreference="SilentlyContinue" Stop-Transcript | out-null $ErrorActionPreference = "Continue" Start-Transcript -path C:\LogFileLocation\IllegalCharsFound.txt -append # DO YOUR EXECUTION COMMAND HERE Check-IllegalCharacters -Path "D:\Egnyte\MCM" Stop-Transcript

PowerShell Upload File to Style Library & Sub-Path Location

function UploadFile2StyleLibraryLocation($WebUrl, [String] $SourceFilePath, [String] $StyleLibrarySubPath) { # Open web $web = Get-SPWeb $WebUrl $file = Get-Item $SourceFilePath write-host "Started Uploading File..." $file.FullName # Open file $fileStream = ([System.IO.FileInfo] (Get-Item $file.FullName)).OpenRead() # Open Style Library $folder = $web.getfolder("Style Library") # Check whether the file is already exists? $File2Replace = $web.GetFile($folder.Url + $StyleLibrarySubPath + $file.Name) if($File2Replace.Exists -eq $true){ $File2Replace.CheckOut() } # Add the file $spFile = $folder.Files.Add($folder.Url + $StyleLibrarySubPath + $file.Name, [System.IO.Stream]$fileStream, $true) # Check in $spFile.CheckIn("Checkin by deploy script 1.7.0") # Finally publish the file $spFile.Publish("Published by deploy script 1.7.0") $MessageFilePath = $WebUrl + "/" + $folder.Url + $StyleLibrarySubPath + $file.Name $MessageFileName = $file.Name write-host $MessageFilePath write-host "Successfully uploaded file $MessageFileName" $fileStream.Close(); $web.Dispose() }

 

Usage:

UploadFile2StyleLibraryLocation -WebUrl "http://win12sp13"` -SourceFilePath "C:\mywork\pwcs-customer\Phase2Development-V1_7_0\Readify.Pwcs.Deployment\V1.7.0\_package\Deploy\Content\promotion.js"` -StyleLibrarySubPath "/Readify/ClientTemplates/"

Mapping an image to use within SharePoint

Scenario:

PWCSTeamSite module has an image file called “TeamSite.gif”, which I would like to use as:

http://pwcs.com.au/_layouts/15/images/PWCSTeamSite/TeamSite.gif

 

so ensure the following settings:

image

 

Physical file location on server:

C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\IMAGES\PWCSTeamSite

[   ] – {SharePointRoot}

[   ] – Template File

[   ] – Images\PWCSTeamSite

EDITING WSP FILES DIRECTLY / MANUALLY (Re-Packaging, makecab) – How To?

Exported site/web template could not be used to recreate the site:

Problem Applying Web Template

This web template requires that certain features be installed, activated and licensed. The following problems are blocking application of the template.

How to Fix?

  • EXTRACT THE WSP FILE

Download a tool like 7-Zip.
Right click the file
Select 7-Zip > Extract to WspName
Go ahead and go into the folders and edit any XML that you may need to. Using the example above you will need to edit the onet.xml file to remove the site collection feature reference.

Right click and extract the wsp file @ C:\Users\msmriyaz\Desktop\SPO-Backup level

  • BUILD THE DIRECTIVE FILE

Download makeddf and drop the makeddf.exe in the same directory as your extracted folder
Open command prompt
Change directory to the location of makeddf
Run the following command

makeddf /p WspName /d WspName.ddf /c WspName.cab

cd "C:\Users\msmriyaz\Desktop\SPO-Backup\SPO-Project Template v1.0"

makeddf.exe /p "SPO-Project Template v1.0" /d "SPO-Project Template v1.0.ddf" /c "SPO-Project Template v1.0.cab"

  • REMAKE THE CAB

Copy the newly created ddf file into your WspName folder

Go back to your command prompt

Change directory into the WspName folder

Run the following command

makecab /f WspName.ddf

Rename your newly created cab file to WspName.wsp and you’re done