首先需要安装 .NET Framework 4.5.2 或更高版本:https://dotnet.microsoft.com/en-us/download/dotnet-framework
然后下载安装 PowerShell 5.1:https://www.microsoft.com/en-us/download/details.aspx?id=54616
如果在执行包含中文内容的脚本时不显示中文,或 Write-Output 中文时出错,如下图:
out-lineoutput : The Win32 internal error "A device attached to the system is not functioning" 0x1F occurred while writing to the console output buffer at the current cursor position. Contact Microsoft Customer Support Services.
+ CategoryInfo : WriteError: (:) [out-lineoutput], HostException
+ FullyQualifiedErrorId : WriteConsole,Microsoft.PowerShell.Commands.OutLineOutputCommand
请注意修改以下配置:
1、在标题栏中点击右键,选择“属性”:
2、切换到字体选项卡,将原有默认点阵字体切换为上方字体:
3、点击确定即可正常使用。
参考:https://blog.51cto.com/jameszhan/2642202