要如何透過url呼叫jenkins的作業呢?

1.先取得crumb(也就是token)

透過http Get 方法,透過base 認證取得內容內容,將

image

image

image

2.將jenkins作業的url貼上,並以POST方式,並將crumbRequestField與crumb內容帶入http Header就可以呼叫

image

image

image

image

3.若作業有參數必須將Build參數改為BuildWithParameters,再將參數的變數使用querystring帶入即可

image

image

image

image

unix要如何設定排程呢?

請參考:Crontab.guru – The cron schedule expression editor

在unix都是透過cron方式進行排程,所以只要在以上網址可以直接輸入要的排程時間,然後將結果複製就可以了。

以下是範例是每天凌晨1:00執行。

image

以下是每小時整點

image

參考:Cron examples – Crontab.guru

參考以上網址有很多範例可以參考

image

SSL憑證格式轉換

參考:SSL Certificate Convertor Guide – Convert Your SSL Cetificate Format W/ OpenSSL Commands (thesslstore.com)

OpenSSL commands to convert PEM file
  • Convert PEM to DER

    openssl x509 -outform der -in certificate.pem -out certificate.der

  • Convert PEM to P7B

    openssl crl2pkcs7 -nocrl -certfile certificate.cer -out certificate.p7b -certfile CACert.cer

  • Convert PEM to PFX

    openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile CACert.crt

OpenSSL commands to convert DER file
  • Convert DER to PEM

    openssl x509 -inform der -in certificate.cer -out certificate.pem

OpenSSL commands to convert P7B file
  • Convert P7B to PEM

    openssl pkcs7 -print_certs -in certificate.p7b -out certificate.cer

  • Convert P7B to PFX

    openssl pkcs7 -print_certs -in certificate.p7b -out certificate.cer

    openssl pkcs12 -export -in certificate.cer -inkey privateKey.key -out certificate.pfx -certfile CACert.cer

OpenSSL commands to convert PFX file
  • Convert PFX to PEM

    openssl pkcs12 -in certificate.pfx -out certificate.cer -nodes

要如何解決出現無法查詢交易計數錯誤訊息呢?

在我們使用ssms 18.2時,常常會出現無法查詢交易計數錯誤訊息,如下,通常這種情形時,突然網路斷線,所開啟的sql查詢頁簽與資料庫沒有斷線,造成當你關閉ssms時,必須每次要去計算交易次數,因為需要等待timeout,所以須要等很久,這個狀況造成很多人困惱,是否有辦法排除呢?

image

其實這個是在ssms 18.x版之後才會有這一個功能,後來發現在ssms 19.x版就有提供一個選項將它勾選拿掉就不會出現了。

image

image

web.config要如何加密後搬移到另一台使用呢?

參考RSA 金鑰對Web.config資料庫連線字串加密 – Program – Medium

步驟

1.建立RSA金鑰 並將金鑰匯出成檔案

set framework_path=C:\Windows\Microsoft.NET\Framework\v2.0.50727

%framework_path%\aspnet_regiis.exe -pc “SBPKeys" –exp(產生金鑰並註冊)
%framework_path%\aspnet_regiis.exe -px “SBPKeys" SBPkeys.xml –pri(匯出檔案方便複製到另一台Server)

Web.config加入configProtectedData

<?xml version="1.0″ encoding="utf-8″?>
<configuration>

:

:

<configProtectedData defaultProvider="SBPProtectedProvider">
     <providers>
       <add name="SBPProtectedProvider"
       type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
       keyContainerName="SBPKeys"
       useMachineContainer="true" />
     </providers>
   </configProtectedData>

</configuration>

2.對 Web.config 連線字串與appsetting內容加密

set ap=sbpclient.exe
set sbpclient_folder=c:\sbpclient
cd %sbpclient_folder%
  %framework_path%\aspnet_regiis.exe -pef “connectionStrings" %sbpclient_folder%  -prov “SBPProtectedProvider"
%framework_path%\aspnet_regiis.exe -pef “appSettings" “%sbpclient_folder%" -prov “SBPProtectedProvider"

3.授權使用RSA金鑰

set framework_path=C:\Windows\Microsoft.NET\Framework\v2.0.50727
set batch_user=%ComputerName%\ssis_win_user(特定使用者或電腦名稱)
set iis_user=IIS APPPOOL\DefaultAppPool(iis的application pool)

%framework_path%\aspnet_regiis.exe -pi “SBPKeys" SBPkeys.xml(匯入金鑰,將步驟1產生的檔案複製到另一台,若同一台不需要執行匯入)
%framework_path%\aspnet_regiis.exe -pa “SBPKeys" “%batch_user%"
%framework_path%\aspnet_regiis.exe -pa “SBPKeys" “%iis_user%"

加密後結果

image

如何透過powershell 寄發Email呢?

參考:Send-MailMessage (Microsoft.PowerShell.Utility) – PowerShell | Microsoft Learn

Send-MailMessage -From ‘f25b-server@systex.com.tw’ -To ‘ccyeh@systex.com.tw’ -Subject ‘Sending the test’ -Body “body. Sending now."  -SmtpServer ‘mail.xxx.xx’ -UseSsl -Credential ccyeh@systex.com.tw

透過以上語法執行後系統會提示輸入密碼後就可以寄發了

image

image

image

透過powershell執行驗證ftp,sftp,ftps方法

參考:

1.GitHub – EvotecIT/Transferetto: Small PowerShell module with FTPS/SFTP functionality

2.Easy way to connect to FTPS and SFTP using PowerShell – Evotec

1.首先先安裝Transferetto Module

Install-Module -Name Transferetto -AllowClobber –Force
2.使用Connect-Ftp連到Server
3.使用Get-FTPList取得清單
範例如下:
  1. $Client = Connect-FTP -Server ‘192.168.241.187’ -Verbose -Username ‘test’ -Password ‘BiPassword90A’ -EncryptionMode Explicit -ValidateAnyCertificate
  2. # List files
  3. $List = Get-FTPList -Client $Client
  4. $List | Format-Table
  5. # List files within Temporary directory
  6. $List = Get-FTPList -Client $Client -Path ‘/Temporary’
  7. $List | Format-Table