内容简介:由於我每次在 Azure 上建立 Windows Server 2016 Datacenter 測試用 VM (虛擬機器) 的時候,都需要在開機後執行特定 PowerShell 腳本,這邊我特別分享出來,方便日後不斷維護與管理。想參考使用的人,請自行調整使用。如果有其他覺得推薦的設定,也麻煩留言分享。由於 Azure 在手動建立 VM 時,可以透過 Custom Script 自動化所有「系統層級」的安裝設定,所以只要跟「使用者」無關的系統設定、服務安裝、應用程式安裝等等,都可以在安裝的同時自動完成。以下
由於我每次在 Azure 上建立 Windows Server 2016 Datacenter 測試用 VM (虛擬機器) 的時候,都需要在開機後執行特定 PowerShell 腳本,這邊我特別分享出來,方便日後不斷維護與管理。想參考使用的人,請自行調整使用。如果有其他覺得推薦的設定,也麻煩留言分享。
首次安裝的 PowerShell 腳本命令
由於 Azure 在手動建立 VM 時,可以透過 Custom Script 自動化所有「系統層級」的安裝設定,所以只要跟「使用者」無關的系統設定、服務安裝、應用程式安裝等等,都可以在安裝的同時自動完成。
以下我直接列出完整命令:
# 設定時區為台北標準時間 (Taipei Standard Time)
Set-TimeZone -Name "Taipei Standard Time"
# 關閉 Internet Explorer 增強安全性設定 (Enhanced Security Configuration)
$AdminIEOff = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}"
Set-ItemProperty -Path $AdminIEOff -Name "IsInstalled" -Value 0
Stop-Process -Name Explorer
# 安裝 Chocolatey 套件管理器 ( https://chocolatey.org/install )
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
# 安裝常用應用程式
choco install webpicmd googlechrome vscode 7zip notepad2 notepadplusplus git everything openssh unxutils wget curl -y
# 因為 Google Chrome 與 Visual Studio Code 都支援自動更新,所以安裝好之後就不用再透過 Chocolatey 進行升級管理
choco uninstall googlechrome vscode --skip-autouninstaller
首次安裝額外的 PowerShell 腳本命令:IIS + ASP.NET
# 安裝 IIS 服務 Install-WindowsFeature Web-Server,Web-Asp-Net45,NET-Framework-Features
首次安裝額外的 PowerShell 腳本命令:IIS + ASP.NET Core 2.1
Install-WindowsFeature Web-Server,Web-Asp-Net45,NET-Framework-Features # Install the .NET Core SDK Invoke-WebRequest https://download.visualstudio.microsoft.com/download/pr/45f93081-cdb4-41c1-8d8d-e6c3bbf2872b/62d6a598956fdfe585acb1f15268d930/dotnet-sdk-2.1.403-win-x64.exe -outfile $env:temp\dotnet-sdk-2.1.403-win-x64.exe Start-Process $env:temp\dotnet-sdk-2.1.403-win-x64.exe -ArgumentList '/quiet' -Wait # Install the .NET Core Windows Server Hosting bundle Invoke-WebRequest https://download.visualstudio.microsoft.com/download/pr/86df96bb-384c-4d7a-82ce-2e4c2c871189/045870c1ab4004219cb312039c5a64d5/dotnet-hosting-2.1.5-win.exe -outfile $env:temp\DotNetCore.WindowsHosting.exe Start-Process $env:temp\DotNetCore.WindowsHosting.exe -ArgumentList '/quiet' -Wait # Restart the web server so that system PATH updates take effect net stop was /y net start w3svc
首次安裝額外的 PowerShell 腳本命令:Hyper-V
Add-WindowsFeature Hyper-V,Hyper-V-Tools,Hyper-V-PowerShell
首次安裝額外的 PowerShell 腳本命令:Windows Containers
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force Install-Module -Name DockerMsftProvider -Repository PSGallery -Force Install-Package -Name docker -ProviderName DockerMsftProvider -Force
首次安裝額外的 PowerShell 腳本命令:Web Deploy 3.6 for Hosting Servers
WebPiCmd /Install /Products:WDeploy36PS,ASPNET45 /AcceptEula /SuppressReboot /SuppressPostFinish /Log:C:\WebPiCmd_Install.log
首次登入的 PowerShell 腳本命令
# 目前 Web Platform Installer 安裝的時候會跳出升級視窗,無法完成自動安裝 choco install webpi -y # 安裝 clink 強化命令提示字元操作 choco install clink -y # 直接設定 Git 預設 user.name 與 user.email git config --global user.email "you@example.com" git config --global user.name "Your Name" # 設定預設 Git Alias git config --global alias.co checkout git config --global alias.ci commit git config --global alias.st status git config --global alias.sts "status -s" git config --global alias.br branch git config --global alias.re remote git config --global alias.di diff git config --global alias.type "cat-file -t" git config --global alias.dump "cat-file -p" git config --global alias.lo "log --oneline" git config --global alias.ll "log --pretty=format:'%h %ad | %s%d [%Cgreen%an%Creset]' --graph --date=short" git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset %ad |%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset [%Cgreen%an%Creset]' --abbrev-commit --date=short" # 設定 git 預設編輯器為 notepad git config --global core.editor "notepad" # 設定 git 預設編輯器為 Visual Studio Code # git config --global core.editor "code --wait" # 設定 git status 若有中文不會顯示亂碼 git config --global core.quotepath false # 設定 git log 若有中文不會顯示亂碼 SETX LC_ALL C.UTF-8 /M # 安裝 TortoiseGit 與設定 git tlog 開啟 Tortoise Show log 視窗 choco install tortoisegit -y git config --global alias.tlog "!start 'C:\PROGRA~1\TortoiseGit\bin\TortoiseGitProc.exe' /command:log /path:."
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Where Wizards Stay Up Late
Katie Hafner / Simon & Schuster / 1998-1-21 / USD 16.00
Twenty five years ago, it didn't exist. Today, twenty million people worldwide are surfing the Net. "Where Wizards Stay Up Late" is the exciting story of the pioneers responsible for creating the most......一起来看看 《Where Wizards Stay Up Late》 这本书的介绍吧!