Setup simple environment to test incoming email function

 

由於我不是真的要發送email到街外, 我只需要啟動IIS6的SMTP service, 設定為open relay (或稱allow relay to everyone), 設定如下:

smtp_properties

另外, 確認一下SMTP的fqdn是否設定好, 選Delivery > Advanced:

smtp_properties2

預設是你的server fqdn (e.g. server1.domain.com), 這兒可以不用改, 記住就可以了. 之後如果要在本機收到email, 電郵地址就要是xxxxx@server1.domain.com

以上的設定, 可以讓本機的smtp轉發(relay)電郵, 而當to address是@server1.domain.com它就不會轉發, 而是儲存在本機硬碟中, 預設路徑為C:\inetpub\mailroot\Drop\

最後, 到SharePoint CA -> System Settings -> Configure incoming e-mail settings, 我是用以下設定的:

incomingemail_setup

之後, 打開任何一個Library > library settings -> incoming email settings. 設定好收件地址, 馬上可以測試了!

有時想要測試SharePoint上的incoming email功能, 或發郵件到其他server, 但又沒有exchange, 用telnet方法去打指令又麻煩(兼不容易加附件), 最近找到個推介的工具SendSMTP: 下載連結 不用安裝, 直接把程式丟到server上面就可以發電郵了

 

 

 

Error: Cannot add the specified assembly to the global assembly cache

Sometimes when deploy farm solution to a multiple machines environment, the error will occur:

solution_error

You may check the ULS Log to find error details. But in my case, it is not useful. The error log just tell me something is conflicted.

As the screenshot indicated, only one of my machine is failed to deploy solution. Another one is deployed successfully.

It is what I do to resolve it:

  1.  Login the machine with error, open DOS prompt with administrator permission, run this command line:
    “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\stsadm.exe" -o retractsolution -name YourWSPfile.wsp -local
    It will try to retract the related dll (most of the case is YourWSPfile.dll) from the local machine only. It is what I got:

    RetractionFailedCouldNotRemoveFile : SERVER02: Error: Cannot remove the specif
    ied assembly from the global assembly cache: YourWSPfile.dll.

    yourwspfile.wsp: Operation completed with errors.

  2. Again there is no useful detail in ULS log. But I remember the deployment is actually processed by Timer service. So I open the services.msc in error server, restart the “SharePoint 2010 Timer" service. Then run the command in step 1 again. This time it return:
    Operation completed successfully.
  3. Then I deploy the solution again by click the “Deploy Solution" in solution management form (in the screenshot provided). Solution is now deployed successfully to all machines.

General procedure to migrate Project Web App 2010 (PWA 2010)

  1. Backup all PWA database:
    Draft database
    Published database
    Archive database
    Reporting database
  2. Expoort the Project BI center subsite. PowerShell command as follow:
    exportspweb http://sharepoint/pwa/ProjectBICenter" path “d:\backup\projectbicenter.cmp"
  3. Move the backup files prepared in step 1 to new SQL server and restore all 4 of them.
  4. Go to destination SharePoint farm CA > Manage service application > Project service application. Create new PWA. In the database field, type in the database server and DB name from step 3.
  5. After the PWA is generated, you should see all projects, resources and workflows etc will be restored. But the BI center is blank (it contains the default lists, libraries and reports only).
  6. Import the subsite backup file we prepared at step 2. PowerShell command as follow:
    importSPWeb http://destination-sharepoint/pwa/ProjectBICenter" path “d:\backup\projectbicenter.cmp" -updateVersions Overwrite
  7. After import, all BI center items should be recovered at destination PWA!

List all permission setup within a library/list

It is always a trouble for SharePoint administrator maintain a library or list’s permission. Because the user can always break inheritance for a nested subfolder. After a while, no one remember the unique permission setup long time ago and it become a unmanaged security risk.

Here is a PowerShell script to scan a specific library or list. Scanned result will be exported to a csv. All the unique permission in each file/item and subfolder will be listed out.

SharePoint admin其中一個時常面對的困難就是「文件庫」或「清單」中設定的獨立權限, SharePoint上沒有很好的管理工具去告知admin哪些file/item有獨立權限, 久而久之文件庫上就會留下一堆沒有懂得管理的文件。

以下是一個簡單的PowerShell程式, 可以掃瞄指定library/list, 然後列出所有獨立權限的設定

param (
[Parameter(Mandatory=$true)][string]$libname,
[Parameter(Mandatory=$true)][string]$weburl,
[string]$OutputPath
)
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#$libname = “Shared Documents"
#$weburl = “http://sharepoint/sites/abc"

$OutputReport = $OutputPath + “LibPermissionReport_" + ($libname -replace ‘[[&+*?()\\.\s]’,’-‘) + “.csv"
#delete the file, If already exist!
if (Test-Path $OutputReport) {
Remove-Item $OutputReport
}
#Write header to Log file
“URL `t Scope `t Title`t permission come from… `t Permission Level `t ($libname)" | Out-File $OutputReport -Append

$web =  Get-SPweb $weburl
$list = $web.Lists[$libname]

foreach ($sf in $list.folders){
if($sf.HasUniqueRoleAssignments) {
$UserPermissions=""
foreach($RoleAssignment in $sf.RoleAssignments) {
$UserPermissions += $RoleAssignment.Member.Name+"["
$rolelist=@()
foreach ($RoleDefinition in $RoleAssignment.RoleDefinitionBindings) {
$rolelist += $RoleDefinition.Name
}
$UserPermissions+=$rolelist -join “,"
$UserPermissions+="];"
}
#Send the Data to Log file
“$($weburl+"/"+$sf.Url) `t Folder `t $($sf.Title)`t Direct Permission `t $($UserPermissions)" | Out-File $OutputReport -Append
}
}

foreach ($item in $list.items) {
if($item.HasUniqueRoleAssignments) {
$UserPermissions=""
foreach($RoleAssignment in $item.RoleAssignments) {
$UserPermissions += $RoleAssignment.Member.Name+"["
$rolelist=@()
foreach ($RoleDefinition in $RoleAssignment.RoleDefinitionBindings) {
$rolelist += $RoleDefinition.Name
}
$UserPermissions+=$rolelist -join “,"
$UserPermissions+="];"
}
#Send the Data to Log file
“$($weburl+"/"+$item.Url) `t File/Item `t $($item.Name)`t Direct Permission `t $($UserPermissions)" | Out-File $OutputReport -Append
}
}

write-host “Report $($OutputReport) generated"

Above code is inspired by SharePointDairy.

 

大家注意Report PDU轉了新syllabus啦

最近登入PMI.org去匯報PDU, 赫然發現Report PDU的介面又改了, 雖然改得比較美觀, 但與以前的匯報方法完全不同呀! 以前是有分成6個類別的, 如下:

Category A: Courses offered by the PMI’s representative
Category B: Continuing Education
Category C: Self-Directed Learning
Category D: Creating New Project Management Knowledge
Category E: Volunteer Service
Category F: Working as a Professional in Project Management

但現在PMI的Report PDUs 介面卻變成這樣:

reportPDU

怎麼變成10類了? 我查了好一陣子, 大家都說新的計算方法依然是6大類, 不是10大類啊, PMI你搞什麼?

新的方法的參考Edward Designer , 其中最令我意外的改動是Cat F最多只能匯報8分, 即使就算你當了Project Manager, 這部份最多只能算8分, 你要用其他方法貢獻PMP社群才可以。

幸好新的計算方法只適用於PMP證書有效日期為2017年12月1日之後的人, 所以我今次還是用舊制去Report PDUs。

 

MS InfoPath

抱歉過了一年沒有更新 (反正除了我也沒人看),概因在前公司網絡管理太嚴,把Wordpress擋了,貼文很不方便,所以就沒寫了。最近轉了公司,才可以貼一年後第一篇文。

在新公司裡用的是SharePoint 2010 Enterprise,這兒大量的使用MS InfoPath, Designer & VS workflow, 以及Event Receiver。這是我第一次接觸InfoPath,比我想像中的還要方便,好用。Microsoft雖然說了InfoPath 2013將會是最後的版本,以後不會有新版本了,但至今(2016年7月)還未有取代方案出現,暫時各大MVP都叫大家改用List form。。。根本是兩件事情,List form所需要的coding太多了,而且都集中以Client side為主,如果Form的邏輯太多,用戶用起來將會非常慢。

如要使用MS InfoPath,公司需要購買SharePoint Enterprise CAL;如果沒有Enterprise只有Standard,那麼所有form的使用者(users)都要安裝InfoPath Filler,不能使用browser去打開form和填form,用戶體驗自然差得多。

在mysite的Newsfeed可以貼圖, 在MySite則不行

如果跟足Microsoft建議的設定, 不同的Web Application要用不同Service Account (即是Application pool帳號), 恭喜你, 應該會遇到這個問題:

在自己的MySite可以貼圖, 在Team site或其他Site則不行.

原因很明顯, 執行Team Site的Web Application的Application pool帳號, 沒有權限寫資料到MySite的Database. 解決很簡單, 在SharePoint powerShell windows輸入以下:

$webApp = Get-SPWebApplication “<my site host>"
$webApp.GrantAccessToProcessIdentity(“domain\SPWebApp")

domain\SPWebApp 是Team Site的Web Application的Application pool帳號

執行後, 會在CA的Manage Web Application看到"domain\SPWebApp"被加到My Site host的Web application上

除此以外, 還會在MySite的Content Database加上權限啊

How People Picker work in SharePoint 2013

In the good old days, I mean SharePoint 2010 and previous versions, you would see People picker control always come with two icons. One is user verification button and another is address book. However in SharePoint 2013, you will find many pages with People Picker control missed these two icons.

在舊的SharePoint版本, People Picker都跟隨兩個小icon, 一個是Check name, 一個是Address book. 但在SharePoint 2013中很多頁面的People Picker control都不見了兩個icon (例如Assign user進SharePoint group的頁), 取而代之的是一個懂Auto complete的People Picker

image

最近遇到一個難題, 在沒有Address book情況下, 來自非SharePoint域名的用戶都加不到, 尋找不到, 即使已經在User Profile Application中確定那些用戶已經同步到User Profile database, 也是加不到. 在People Picker中輸入域名和用戶名, 都出現No exact match was found的錯誤。

我先直接講一下People Picker如何回傳結果, 首先, 當用戶輸入字元時 (可以是login, 中英人名, 或email)都有可能搜索到, People Picker會回傳以下三點的結果:

1. Client side Cache (並非在Browser history而是在Registry DomStore — HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\LowCache\Extensible Cache\DOMStore, 參考),
2. 指定的Domain Controller
3. 查找該people picker所在的Site Collection的User Information List (中文版Sharepoint會叫作「用戶資訊清單」

第1點方面, 只要用Browser的privacy mode就可以忽略

第2點, 預設People picker只會向SharePoint所在的domain DC詢問, 我上面遇到的就是這個問題, 我的SharePoint farm是裝在domainA.com之下. DomainA.com與DomainB.com是one-way trust, 必須要使用stsadm來設定好People Picker才懂得去找另一個域名的。(參考 Configure People Picker in SharePoint 2013)

致於第3點, 也是一個曾經令我頭痛的地方, 在我還未有設定好People Picker去查找DomainB.com前, 有一些Site Collection卻神奇的可以加DomainB.com的某些用戶, 有些則不能。要看User Information List有兩個方法, 一個是用PowerShell去列出來, 另一個是在網站URL後面加上/_Catalogs/Users/simple.aspx。使用PowerShell可以update, delete, add用戶, 但使用simple.aspx就只有readonly

User Information List是在以下情況下才會加入新名字的:
1. 有用戶被Assign到該Site collection底下的group
2. 有用戶在該Site Collection下觸發任何Change (add, modify, delete). 例如該SC容許Everyone參與權限(例如討論區), 任何用戶就可憑藉Everyone所授與的權限去make change, 然後被加到User Information List, 注意這並非即時的, 大概要3-5分鐘的時間

Office Web App fail to provide preview

公司的SharePoint 2013 farm, 裝備了Office Web App, 可以不用打開文件直接透過瀏覽器Preview.

但新安裝好的場遇到一個問題, 就是Excel文件都不能Preview, Mouse點下去只出現錯誤, 其他Word, PowerPoint, OneNote都能正確Preview

後來發覺是OWA不可以一開始就設定為View-only mode, 必須先以預設定「Edit and view」模式建立過一些文件, 然後才換成View-only.

設成Edit and view的PowerShell 如下:

Import-Module OffWebApps
Set-OfficeWebAppsFarm -EditingEnabled:$true

之後需要iisreset OWA

順帶一提要用OWA來編輯文件, 需要購買相關License, 一般來說只要用戶有MS Office 2013的license就可以用了:
http://technet.microsoft.com/en-us/library/ff431685(v=office.15).aspx

Office Web Apps licensing offers two options:

  • View-only. By default, Office Web Apps is view-only. View-only functionality is provided for free.
  • Edit and view. You’ll need to purchase an editing license to use the editing features of Office Web Apps with SharePoint 2013. You enable editing when you create the Office Web Apps Server farm.

If your organization licenses Office 2013 through a Volume Licensing program, you can enable Office Web Apps editing for SharePoint 2013 on-premises. This helps make sure that users have Office editing capabilities at home or in other locations where Office clients might not be installed. Editing licenses for Office Web Apps are not available for separate purchase.

For exact details about your license, refer to the Microsoft Software License Terms that is shown when you install Office Web Apps Server.

SharePoint 2013 provides new license enforcement that works with Office Web Apps. If you enable SharePoint licensing and then enable Office Web Apps editing, only the users who have the appropriate license can actually edit Office files in a browser. If no Office Web Apps editing licenses are applied for users, only viewing is supported.

For more information about how licensing works in SharePoint 2013, see Configure licensing in SharePoint Server 2013. The EditingEnabled parameter that enables editing is described in New-OfficeWebAppsFarm and Set-OfficeWebAppsFarm.

Files that are sent by the Share by link feature in SharePoint 2013 can be edited in Office Web Apps even when no editing license is present and when editing is disabled for the Office Web Apps Server farm.