Pages

2017年9月11日 星期一

Open Full Screen Chrome using cmd


The command as below:

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --start-fullscreen www.google.com

Close and open IE using cmd


The command as below:

Close IE process
taskkill /f /im "iexplore.exe"

Open IE
"C:\Program Files\Internet Explorer\iexplore.exe"

2017年7月27日 星期四

Using PowerShell Script to get Server/PC Drive Space


公司裡目前沒有server的監控程式,所以需要手動的去監控每個server的空間還夠不夠,但server實在太多了,所以才想用以下簡單的script來把所有server的硬碟資訊彙整到excel。

PowerShell script如下:
gwmi win32_logicalDisk -filter "drivetype = 3" -ComputerName server1, server2, pc1, pc2
Select SystemName, deviceid, 
@{Name="Free%";Expression={[math]::Round($_.Freespace/$_.Size,2)}}, 
@{Name="FreeGB";Expression={[math]::Round($_.Freespace/1GB,2)}}, 
@{Name="SizeGB";Expression={[math]::Round($_.Size/1GB,2)}} |  
Sort Free% |
Export-Csv -Path C:\DriveSpace\DrivesSpace-$((Get-Date).ToString('dd-MMM-yyyy_Hmmss')).csv
  • 把上列script貼到筆記本,更改server名字,另存成 .ps1檔,就可以執行。
  • 結果會匯到C:\DriveSpace (自行更改路徑)存成.csvˇ檔案可以用excel開啟。
  • 輸出的freespace及size是以GB為單位。
  • 由於要使用Windows Task Scheduler自動執行,所以檔名有加上執行日期及時間,日期格式請自行更換。
用.bat來執行.ps1
script如下:
Powershell.exe -ExecutionPolicy Bypass -File "DriveSpace.ps1"
  • 把上列script貼到筆記本,更改.ps1檔名字,另存成 .bat檔,就可以執行。

2017年7月13日 星期四

Stop and Disable Firewall on Centos 7


要停止及禁用防火牆的command如下:

Stop Firewall
  sudo systemctl stop firewalld

Disable Firewall
  sudo systemctl disable firewalld



如要確認Firewall的狀態
  sudo systemctl status firewalld

2017年6月30日 星期五

在SQL轉換JDE Julian Date


在JDE System的Database裡的日期,都是以Julian Date的格式儲存
例如: 2017年1月1號 = 117001, 2016年12月31號 = 116366

所以在用SQL抓取Database裡的日期欄位時,就需要做轉換的動作
我使用SQL的語法如下

DateAdd(Day, [Julian Date]%1000 - 1, CAST(CAST(CAST(([Julian Date]/1000+1900) AS Int) AS VarChar(4)) + '-01-01 '  AS Date))

[Julian Date]為需要轉換的欄位

1. 將Julian Date轉換為年分 :  116366 = 2016
    CAST(CAST(([Julian Date]/1000+1900) AS Int) AS VarChar(4))
2. 再將年分轉換為日期 (其年分的第一天) : 116366  = 2016-01-01
    CAST(CAST(CAST(([Julian Date]/1000+1900) AS Int) AS VarChar(4)) + '-01-01 '  AS Date)
3. Julian Date轉換為天數 : 116366 = 365
    [Julian Date]%1000 - 1
4. 使用DateAdd函數將2&3組合

顯示結果如下

2017年6月22日 星期四

在 CentOS 7 安裝 xrdp


安裝xrdp的目的是為了可以用Windows Remote Desktop連線到 Linux Server (CentOS 7)

1. 先在 /etc/yum.repos.d/ 裡建立一個repository file (xrdp.repo)
   # vi /etc/yum.repos.d/xrdp.repo
其內容為
   [xrdp]
   name=xrdp
   baseurl=http://li.nux.ro/download/nux/dextop/el7/x86_64/
   enabled=1
   gpgcheck=0

2. 安裝xrdp
   # yum -y install xrdp tigervnc-server

3. 啟動xrdp service
   # systemctl start xrdp.service

4. 設定開機後自動啟動
   # systemctl enable xrdp.service

5. 建立 iptables rule,允許外部連線
   # firewall-cmd --permanent --zone=public --add-port=3389/tcp
   # firewall-cmd --reload

6. 配置SELinux
   # chcon --type=bin_t /usr/sbin/xrdp
   # chcon --type=bin_t /usr/sbin/xrdp-sesman

7. 用Remote Desktop連線測試
    成功....!

2017年6月10日 星期六

便宜的SSL憑證


由於公司的web service的使用對象都是公司的員工,並沒有外部使用者,所以公司選用了一個免費SSL憑證 (StartSSL),目的只是為了在使用者登入前不會看到不信任的頁面及紅色警告圖示。
但在2016年尾的時候,StartSSL陸續的被各個瀏覽器列為不信任,導致我們必須去找其他便宜的方案,最後我們找到了SSLS.com
比起其他一年USD10.00起跳的價位來看,我們買的三年USD14.97的價錢相對划算很多,而且操作還蠻簡單的。
或許還有其他更便宜或是免費的SSL憑證,但這是我們在半天內能找到的可行方案。
 
 
Blogger Templates