捐血一袋救人一命

2019年5月15日 星期三

用 PowerShell 重新啟動網卡

最近公司的系統突然發生怪狀況,伺服器會不定時斷線,但完全相同的其他三台伺服器,卻不會發生斷線狀況! 當斷線狀況發生時,將網卡停用後,再重新啟用網卡可以讓網路回復連線,所以寫了一隻程式暫時處理 程式流程很簡單,就是會出毛病的伺服器去 ping 閘道 IP,ping 不到就表示斷線了,那就停用網卡,再啟用網卡 $IP = "192.168.123.1" do{     $datetime = Get-Date -UFormat "%Y/%m/%d %A %H:%M:%S" # 去 ping 閘道 IP     if (Test-Connection -IPAddress $IP -Count 1 -ErrorAction SilentlyContinue){     Write-Host $datetime, " Server is Up" }else{     Write-Host $datetime, " Server is Down" # 停用網路卡         Disable-NetAdapter -name "Ethernet0"...

使用 PowerShell 建置 IIS FTP Server

# 要載入此模組才有 IIS 相關指令功能 Import-Module WebAdministration # 站台名稱 $FTPSiteName = 'Your IIS FTP Site Name' # FTP 伺服器目錄 # ex $FTPRootDir = "D:\FTPRoot" $FTPRootDir = 'FTP Root Folder Path' # FTP 伺服器通訊埠 $FTPPort = 21 # FTP 使用者帳號 $FTPUserName = "Your Account" # FTP 使用者密碼 $FTPPassword = 'Your Password' # FTP 使用者群組名稱 $FTPUserGroupName = "FTP Users" # 建立 FTP 伺服器目錄 If(!(Test-Path $FTPRootDir)){     new-item $FTPRootDir -itemtype directory     Write-Host ("Create " + $FTPSiteName + " FTP Folder") -ForegroundColor Blue -BackgroundColor...