2012年11月26日 星期一

VMware縮減硬碟空間

VMware 可以很方便的增加硬碟空間,但怎麼縮減硬碟空間(shrink harddisk in VMware Client )呢?

查了一下,必需使用VMware converter 來重新Create 一個Client,借由重設Hardware的機會下,重設Harddisk的Quota.

http://www.techrepublic.com/blog/networking/how-to-shrink-a-vmdk-using-vmware-converter/5362

其間出現: Unable to obtain hardware information for the selected machine.

查了半天是 Firewall 問題,操作的Converter Client 必需能連上VM Source Client 的Host Server,查log是走902的Port.

2012年11月18日 星期日

Ubuntu apt-get update 出現連線失敗..?

Ubuntu 下 : sudu apt-get update 更新到後面.. 出現連http://tw.archive.ubuntu.com 連線失敗..

該怎麼辦呢?

1. cd /etc/apt : 到 /etc/apt/下
2. vi source.list : 以vi 修改 source.list 檔
3. 更新來源由 tw.archive.ubuntu.com 改為 us.archive.ubuntu.com
以下列指令整批修正  :
:1,$s/SourceWord/DestWord/g : 整批修正
:1,$s/SourceWord/DestWord/gc: 整批修正, 逐一確認再替換 
4. :x! : 存檔

2012年11月15日 星期四

Win7 的硬碟變成了可移動式裝置??

怪了..

Win7 中硬碟不是插在主機板上,怎麼會變成可移動式裝置? 

原來是: 硬碟啟用AHCI mode後,需在加裝 Intel 的Rapid Storage Technology.. 

以M4610為例: 到Acer網站下載Intel 的 SATA driver 即可! 




2012年10月2日 星期二

Sharepoint 搜尋 File Server 個人碟的Security設定

一般公司都會配給員工個人碟,讓員工能夠將公司資料或重要資料放在網路上,一則有定時備份的好處,不怕因個人NB Hardware 問題而毀損,一則能讓Citrix/Remote Server 等一些特定程式使用共用的Data 區域。
但是 File Server 的Share Folder 該如何正確設定,才能讓 個人資料不會被其他人搜詢出來呢?

環境假設:
Server Name: FileServer1
分享目錄:ShareFolder
員工1:Staff1 的個人碟:\\FileServer1\ShareFolder\Staff1
員工2:Staff2 的個人碟:\\FileServer1\ShareFolder\Staff2

首先,分享目錄(\\FileServer\ShareFolder)有兩個設定權限的地方:Sharing 及Security
Sharing 的成員設定 Domain users 具有讀/寫(Read/Write),如果 Security 成員也設定Domain User,雖權限只給Folder 瀏覽權限,但子目錄 Staff1 將繼承Domain User 具Folder 瀏覽權限。

於sharepoint 搜尋的結果,將造成所有人都可搜詢出Staff1 的資料,雖點選路徑後,無法進入,但部份資料已於搜詢上顯示出來,實為不當。

經測試後,只需將分享目錄的Security 上的Domain User刪除。於子目錄 Staff1 的Security上保留Staff1的Modify 權限,不能讓使用者瀏覽(\\FilerServer1\ShareFolder),但能讓使用者直接開啟目錄(\\FileServer1\ShareFolder\Staff1 )。

這樣的設定權限,讓Sharepoint 顯示搜尋結果時,只會顯示自己有權限的目錄資料。

參考文章

2012年8月29日 星期三

Excel 表格中取出長路徑字串中的檔名

我有一個Excel 的Cell,是一長串的檔名路徑,我只要取最後的檔名,這困擾著我..
[
\Device\HarddiskVolume4\partir\Lotus\Notes\framework\shared\eclipse\features\com.ibm.collaboration.realtime.telephony.prod.feature_8.0.2.20100802-0849\feature_hu.properties
]
有一些formula 如 Left(B) / Right(B) / Find / SEARCH ,感覺沒一個可用的,算了..
自己建一個 Formula 來處理吧!

作法:

1. 開啟 Excel 2010 及文件
2. 移至[檢視]
3. 點選[巨集]
4. 填入巨集名稱: [RightOfBackSlash] -> 建立
5. 自動開出一個模組(Module1)於VBAProject 中,將下方程式貼上

Function RightOfBackSlash(strTmp As String)
    While InStr(strTmp, "\") > 0
        strTmp = Right(strTmp, Len(strTmp) - InStr(strTmp, "\"))
    Wend
     RightOfBackSlash = strTmp
End Function
6. Formula 建立完成
7. 於Excel 的New Cell中 ,填上 =RightOfBaclSlash( "OldCell")
8. 完成, 自動取出最後一個檔名




2012年8月3日 星期五

使用GPO關閉Windows Services

最近防毒軟體新版的網頁防禦功能有點問題,將部份使用IP為網站的網頁,認定為惡意網站,相對的,網站 Redirect 的行為通通被防毒軟體檔下來,連開啟default.htm都不行,甚為困擾!

還好Windows GPO可管理 Services,將Services設為Disable 即可。在此稍稍記錄..以免忘記!!

1. 建立[Disable_SWI_Serivces]的GPO

2. 編輯[Disable_SWI_Service]的GPO:於[Computer Configuration] =>  Policies => Windows Settings => Security Settings => System Services => 選擇要Dsiable 的Services

3. 設定Service: 勾選[Define this policy setting]來啟動設定 =>設定狀態為[Disabled] =>確認並關閉編輯



4. 套用GPO到適當的OU

5. Windows Client 下: gpupdate /force 來立即更新




2012年5月14日 星期一

Lync 查找原始分機擁有者的方法

Lync Enterprise Voice 設定的分機重覆了,無法設定給新人,怎麼找到舊的設定者 ?

設定使用者的Lync Enterprise Voice 時,Line URI 欄位不得重覆,如果新人要設定時,會出現下列的錯誤訊息:
Filter failed to return unique result, "[SipAddress : sip: tester@demo.com] [LineURI : tel:+856277][PrivateLine : tel:856277]"
由此得知已有使用者使用過 tel:+856277,

可使用Get-CsUser -Filter {LineURI -eq "tel:+856277"} 的方式找出舊的擁有者或離職者.

其他 Filter 的相關Operator 可看參考

2012年5月7日 星期一

SAP Client 登入訊息伺服器錯誤

SAP GUI 710發生"登入平衡發生錯誤88: 無法連線至訊息伺服器(rc=9)" 的錯誤訊息。

必需檢查 c:\windows\system32\drivers\etc下的Services file, 是否有訊息伺服器使用的Port號: 
如: sapmsXXX  36<XX>/tcp 


2012年4月27日 星期五

使用VBScript將OU內的User名稱改大寫


要將OU內的所以使用者名稱,將英文小寫部份都變更為大寫。
爬文了一下, 原來DN (distinguishedName) 是不能用 objUser.put 方式來改的..
要用Move的方式來處理..
如下 : 將User Object 由原來的名稱, 移到大寫的新名稱的位置.

' Change DN (distinguishedName) to UpperCase by VBScript
' -----------------------------------------------'
Option Explicit
Dim objOU, objUser , UName, LName
Set objOU = GetObject("LDAP://ou=OU1,dc=demo,dc=com")
For each objUser in objOU
If objUser.class="user" Then
LName = objUser.displayName
UName = UCase(objUser.displayName)
objUser.Put "displayname", UName
objUser.Put "givenName", UName
objUser.Put "sAMAccountName",UName
objUser.SetInfo
GetObject(objUser.parent).moveHere ObjUser.adspath,"CN=" & UName
End If
Next

2012年4月9日 星期一

How to delete files after archiving in Schedule tasks

發現一個目前是winrar 獨有的功能, delete files after archiving , 下的參數是  rar -df , 目前download winrar 4.11 是具備此功能的,其他如 7zip / winzip 目前都沒有發現對應的功能.

把它寫成一個VBS

strshell = "RAR.exe a -r -df d:\arc\demo-datetime.rar  d:\datafolder\"
result1 = wshshell.run (strshell,0,False)


放到 WIN2k8做成排程

怪了..居然可以壓縮,但不能刪除舊檔..??

Why?

查了一下 Task Security Context ,是權限不足,勾選排程的"run with highest privileges", 即可正常執行.







2012年3月28日 星期三

Trixbox Trunk改善連線的參數: qualify

Trixbox 與Lync 之間,由 Lync 撥回 Trixbox 都是正常會通的。反過來,由 Trixbox 撥到 Lync 有時撥的通,有時撥不通,應該不是網路的問題。困擾了很久..

今天查了一篇討論,建議在 Trixbox Trunk 最後面加一個參數: qualify=yes 並重新啟動 Asterisk (Trixbox UI => System => System maint => Reset Now)

FreePBX在下面這段提到 qualify=yes 能monitor 網路的建康狀況:
The setting of qualify=yes is technically not needed but allows you to monitor the health of the internet connection in Asterisk, and if not doing any port forwarding, keeps the NAT pinhole open.


目前測試 Trixbox 已能正常連上 Lync, Trixbox => PBX => PBX Status => SIP peers 的Status 由 unmonitored變為OK( 2 ms) 。

其他 Document 可參看這.

2012年3月26日 星期一

VB.NET 的Send Mail內容在Notes Client未正常換行..

記錄一下:
用VB.NET 開發Send mail 的通知,用System.Net.Mail.SmtpClient 的Function
透過SMTP Server 轉給Domino, Client 是IBM Lotus Notes 8.5.2 ,在換行上寫法不同在不同Client 有不一樣的效果.

範例如下:
   MsgBody = "Test line 1" + </br> + "Test line 2"
   MailMessage.IsBodyHtml = True
   MailMessage.Body = MsgBody.ToStrinng

在Notes 8.5.2 Basic Client 會得到:
Test line 1 Test line 2 <<=同一行,沒換行效果

在Notes 8.5.2 Standard Client 會變成:
Test line 1   <<=會換行
Test line 2

改用 <p> 取代<br>會多跳一行,MsgBody = "Test line 1" + </p> + "Test line 2"


在Notes 8.5 Standard Client 與 Basic Client 都會變成:
Test line 1

Test line 2
雖然多跳一行不美觀,但至少能換行,不然就要用別人的元件囉~

另外有人寫到 Environment.Newline ,或"\r\n" ,我測試後都沒效果。
供參考~

2012年3月23日 星期五

壓縮SQL Server的Transation Log


記錄一下..免得久久找一次.
有用的方法來抑制SQL DB的Log快速成長:
1. 不重要的DB,將Recovery Mode 改為Simple:DB->properties->options (自動記錄截斷)
2. 壓縮Transaction Log DB:
壓縮SQL Server的Transation Log(交易記錄檔)
USE <DB_NAME>   --<DB_NAME>:資料庫名稱
DBCC SHRINKFILE([<DB_NAME>_log],2)    --<DB_NAME>_log:ldf檔的邏輯檔名

Ex: 壓縮OCS DB的Log
USE OCSDB
DBCC SHRINKFILE(OCSDB_log],2)

更多說明可看出處:http://msdn.microsoft.com/zh-tw/library/ms345583.aspx

2012年3月14日 星期三

Terminal Server 內的檔案為什麼不能刪檔案?

Windows 2008 ˉTerminal Server有時多人登入後,不知道為什麼偏偏有一個檔案不能刪,
點選刪除時,出現 Access is denied.
點選檔案右鍵=>[屬性Properties]=>[安全Security] =>[進階Advanced]=>
[Permissions]標籤 =>顯示 you do not have permission to view or edit this object's permission settings
[擁有者/Owner] 標籤=> [編輯/Edit] => [Change owner to] 挑選新Owner => [套用/Apply]
也無法變更。

明顯是某個執行中的程式正咬住,但又不知是誰?
安裝 Unlocker 1.19 後,http://download.cnet.com/Unlocker/3000-2248_4-10493998.html
點選檔案右鍵=> unlocker =>即顯示Lock檔案的程式/程序ID(pid)/執行者等資訊.
請相應使用者退出後即可刪除.

2012年3月8日 星期四

如何整批啟用Lync User及更改設定?

整批更新Lync User,簡單的更新可以用Command 方式處理, 複雜的更新只能用批次處理:



1.    啟用Lync : 單一用戶(以LyncUser1為例)
Enable-CsUser -Identity "LyncUser1" -RegistrarPool pool.lync.com -SipAddress sip:lyncuser1l@lync.com

2.      啟用Lync : 以OU整批啟用
Get-CsAdUser -OU "ou=demo,dc=lync,dc=com" | Enable-CsUser -RegistrarPool " pool.lync.com " -SipAddressType EmailAddress -SipDomain lync.com

3.     啟用LyncUser1的 Enterprise Voice
      Set-CsUser -Identity "CN=lyncuser1,OU=demo,dc=lync,dc=com" -EnterpriseVoiceEnabled $True -LineURI tel:+8001


4.    整批啟用Enterprise Voice, 試了很久, 最簡單的方式是用PowerShell: 
需有一個Shell script : 例如: demo.ps1 
匯入資料: 例如: user.csv 
輸出結果到執行目錄上: AssignLineUri-yyyy-mm-dd-xxxx.txt 型式


a.將下列資訊存成: demo.ps1 

param( [string] $importfile = $(Read-Host -prompt "Please enter a file name"))
$importedusers = Import-Csv $importfile

$transcriptname = "AssignLineUri-" + (Get-Date -Format s).replace(":","-") +".txt"

Start-Transcript $transcriptname

foreach ($importeduser in $importedusers)
    {
        $UserDN = "CN=" + $importeduser.SIPUser + ",OU=demo,dc=lync,dc=com"
Set-CsUser -identity $UserDN -EnterpriseVoiceEnabled $True -LineUri $importeduser.LineUri –Verbose
    }
Stop-Transcript



b.將使用者資訊及話機號碼設成: User.csv

SIPUser,LineUri
lyncuser1,tel:+8001
lyncuser2,tel:+8002


c. 操作方式: 
於Start =>Lync Server management shell => <shell directory>\demo.ps1 
輸入: user.csv 
查看結果





其他簡體的啟用範例: 
http://bbs.winos.cn/archiver/tid-117393.html


PowerShell 的啟用範例: 
http://blogs.technet.com/b/csps/archive/2010/06/10/scriptmoveusers.aspx
http://blogs.technet.com/b/csps/archive/2010/06/10/scriptassignlineuris.aspx

2012年2月23日 星期四

如何將 Lync 與 FreePBX/ Trixbox 整合


花很多時間將 Lync 2010 FE 透過 Lync Mediation Server 連接FreePBX( Trixbox),如果沒有做成文件,以後一定會找不到。

所需的東西:
1. TrixBox (目前可抓到 Trixbox 2.8.0.4 CE) , 相關說明如下
http://www.diybl.com/course/6_system/linux/Linuxjs/2008106/148288.html
http://www.msexchange.org/articles_tutorials/exchange-server-2010/mobility-client-access/how-configure-unified-messaging-asterisk-sip-gateway-part2.html

2. Client : 3CXPhone
http://www.3cx.com/VOIP/voip-phone.html

3. TrixBox 設定方法:
http://www.fintechcommunications.com/blog/?p=60
http://imaucblog.com/archive/2009/10/03/part-1-how-to-integrate-exchange-2010-or-2007-with-trixbox-2-8/

4. Lync 設定方法:
http://www.circuitid.com/blog/lync-setup-guide-using-circuitid-part-1-configuring-mediation-server
http://www.circuitid.com/blog/lync-setup-guide-using-circuitid-part-2-configuring-voice-routing

5. 注意事項:
Lync 內部都走E.164 (+開頭的Formate,例如:+2015),如果透過SIP Trunk丟給PBX時,有的FreePBX 不接受"+"號,需將+號移除。

這個動作在Lync 叫 : Outbound route translation ,(說明請看:Translating Outbound dials strings)
http://technet.microsoft.com/en-us/library/gg412757.aspx
http://technet.microsoft.com/en-us/library/gg425831.aspx
http://blogs.technet.com/b/csps/p/uimap59.aspx

如果效果是要將E.164 的formate (例如:+2015) 往 PSTN Gateway 送時,就會取消"+",為 2015 。  
則可於Trunk Configuration 內這樣設定:
Starting digits = +2 : 開頭為+2
Length= exactly 5 : 這裡的Length 是說含加號,共五碼 (例如: +2015)
Digits to remove = 1 : 移除第一碼,即加號
Digits to add = "": 不加上任何字元
http://designinglync.blogspot.com/2011/05/lync-dial-plans-and-normalization-rules.html

6. 語音/視訊通訊最低頻寬說明:
http://technet.microsoft.com/zh-tw/library/gg398334.aspx

7. Trixbox 有用的說明
http://www.freepbx.org/support/documentation/howtos/howto-setting-up-voip-provider-trunks/freepbx-sip-trunks-powered-by-ban

2012年2月7日 星期二

archive system log by schedule tasks


' 由於某些軟體會產生大量的檔案,特建立備存機制,
' 1. 將特定目錄下的子目錄都備存起來,並刪除空的子目錄
' 2. 需先安裝WINRAR
' 3. 將下列程式做成.vbs 檔案
' 4. 建立Task schedule , 將備存的目錄設為參數
'
'--- .vbs 程式開始
Option Explicit
 
' 宣告變數
Dim FSO, agoDays, modifiedDate, ArcFolder  ,myArgs, GetDateTimeFM, wshshell

' 建立檔案系統物件(File System Object)
Set FSO = CreateObject("Scripting.FileSystemObject")
' 建立執行的shell 物件
Set wshshell=createobject ("wscript.shell")
'取得第一個變數
Set myArgs = WScript.arguments
' 欲備存檔案所在之目錄    
ArcFolder = myArgs(0)
' 取得日期(yyyy_mm_dd_hh_nn_ss)
GetDateTimeFM = GetFormattedDateTime()

' 呼叫備存檔案的子程序
ArcFilesInFolder FSO.GetFolder(ArcFolder)    

' 呼叫刪除空Folder的子程序
DelFoldersInFolder FSO.GetFolder(ArcFolder)    

' 備存目錄的子程序
Sub ArcFilesInFolder(folder)
  ' 宣告變數
  Dim file, subFolder,strshell
  ' 如果遇到子目錄,也要進去檢查並刪除
  For Each subFolder in folder.SubFolders
      strshell = "WinRAR.exe a -r -df " + SubFolder + "-dt-" + GetDateTimeFM + ".rar " + subFolder + "\"
      Call wshshell.run (strshell,0)
Next
End Sub  

' 刪除檔案的子程序
Sub DelFoldersInFolder(folder)
  ' 宣告變數
  Dim dfile, dsubFolder, fdEmpty  
  ' 如果遇到子目錄,要先進去檢查並刪除
  For Each dsubFolder in folder.SubFolders
      DelFoldersInFolder dsubFolder
Next  
  fdEmpty = True
  ' 找出目前所在目錄內所有的檔案
  For Each dfile In folder.Files ' 檢查檔案日期是否符合條件,若符合,就刪除
      fdEmpty = False
  Next    
  For Each dsubFolder in folder.SubFolders
  fdEmpty = False
    Next
    If fdEmpty = True Then
    folder.delete
  End If
End Sub  

' 取得日期的函式
Function GetFormattedDateTime
  Dim strNow, strDD, strMM, strYYYY,strHH,strNN,strSS
strYYYY = DatePart("yyyy",Now())
strMM = Right("0" & DatePart("m",Now()),2) 'month
strDD = Right("0" & DatePart("d",Now()),2) 'day
strHH = Right("0" & DatePart("h",Now()),2) 'hour
strNN = Right("0" & DatePart("n",Now()),2)  'mintue
strSS = Right("0" & DatePart("s",Now()),2) 'second
GetFormattedDateTime = strYYYY & "_" & strMM & "_" & strDD & "_" & strHH & "_" & strNN & "_" & strSS
End Function
'--- .vbs 程式結束

2012年2月6日 星期一

How to archive Discussion Application in Lotus Notes?

開發過Lotus Notes 應用系統系統的都知道,只要文件Copy再貼上,@DocumentUnid 一定不一樣,因次,應用系統通常都會自己建一個 UniqueID 欄位,來處理文件複製/貼上而造成相關文件對應不起來的這種問題。

但是, Discussion 是一個特別的資料庫,它是討論區,既然是"討論",就會有前/後(主文/回應/回應的回應)的問題,除非所有預設的View 都再客制,否則無法以自製 UniqueID來處理前/後文關係,因此通常都不再客制Document ID欄位。

這時後的備存,只能使用系統預設的備存工具,來保留資料移動到不同系統/目錄時,仍能有相同的Document ID。

1. 先設定Archiving Rule : Database => Properties => Archive Setting => Archive settings 設定視窗
   Basics => 設定目的地 (A Server 到 B Server )
   Criteria => 同Mail , 設定那些目錄需備存
   Advanced => 正常備存後刪除
   Schedule => 不能設...怎麼辦? 
2. 設定代理程式,自動啟動備存排程: 
Dim s As New notessession
Dim db As notesdatabase
Set db = s.currentdatabase
Call db.archiveNow()
Exit Sub

2012年1月19日 星期四

每天自動刪除過期檔案(Delete Files over than n days)

File Server 雖是儲存空間,但也不必要永久存放,如果已經進磁帶備份後,很多參考用的大檔案是可以刪除的。

研究了一下 VBScript 自動刪除的機制,將下面的.vbs File 加到Server 的Schedule Tasks ,再加上絕對路徑當參數,就可以自動刪除了。

------------------ 以下作成一個 delFolderFilesOverThan60days.vbs --------


' 指定所有變數必須事先宣告才能使用
Option Explicit
 
' 宣告變數
Dim FSO, agoDays, modifiedDate, delFolder  ,myArgs

'If WScript.arguments.length <> 0 Then
' WScript.quit  
'End If

' 建立檔案系統物件(File System Object)
Set FSO = CreateObject("Scripting.FileSystemObject")

' 請將下面的變數值換成你要的
' 指定 n 天前的檔案,現在是 3 天前
agoDays = 60
' 取得檔案的修改日期
modifiedDate = DateAdd("d", -agoDays, Date)  

Set myArgs = WScript.arguments

' 欲刪除檔案所在之目錄    
delFolder = myArgs(0)

' 呼叫刪除檔案的子程序
DelFilesInFolder FSO.GetFolder(delFolder)    

' 刪除檔案的子程序
Sub DelFilesInFolder(folder)
  ' 宣告變數
  Dim file, subFolder
 
  ' 找出目前所在目錄內所有的檔案
  For Each file In folder.Files
      ' 檢查檔案日期是否符合條件,若符合,就刪除
      If ((file.DateLastModified <= modifiedDate)) Then
          file.delete
      End If
  Next
 
  ' 如果遇到子目錄,也要進去檢查並刪除
  For Each subFolder in folder.SubFolders
      DelFilesInFolder subFolder
Next
End Sub  
 
'WScript.Echo("作業執行完畢:" & Date & " " & Time)

----------------------------------

程式的參考出處:

http://ithelp.ithome.com.tw/question/10009001
http://ithelp.ithome.com.tw/question/10058183