1.安装visual studio code

2.安装powershell extension

3.打开脚本文件

4.F1,然后输入format,找到format document的选项

但是这个用起来有点不太理想,傻乎乎的。

 

 

PowerShell Beautifier

通过导入powershell module进行操作,module提供了函数

  1. Download the PowerShell Beautifier utility. Clone it, zip it or get it from the PowerShell Gallery:
Install-Module -Name PowerShell-Beautifier
  1. Import the module. This takes a few seconds the first time but is fast thereafter.
Import-Module PowerShell-Beautifier.psd1
  1. Confirm it is loaded correctly:
Get-Help Edit-DTWBeautifyScript

很神奇的是,这里的import-module不需要每次都导入。直接集成在了内部

http://www.brianbunke.com/blog/2017/01/09/publishing-scripts/   参考这个文章看了一下,原来是把module放到了以下目录,在启动的时候自动加载

 C:\Users\clu\Documents\PowerShell\Modules

 

查看已经安装的module

Get-InstalledModule

Version Name Repository Description
------- ---- ---------- -----------
1.2.5 PowerShell-Beautifier PSGallery PowerShell beautifier / code cleaner / p…0.0.1 WindowsCompatibility PSGallery This module Provides compatibility utili…

 

相关文章:

  • 2022-01-25
  • 2022-12-23
  • 2022-03-06
  • 2021-11-21
  • 2022-12-23
  • 2022-01-17
  • 2021-09-20
  • 2021-11-20
猜你喜欢
  • 2021-06-17
  • 2021-06-17
  • 2021-12-03
  • 2021-08-11
  • 2022-02-16
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案