以前没有用过powershell,从头开始学习,看到网上好些教程上来就将历史什么的,觉得有些啰嗦,就想写一个简单实用的入门教程,顺便记录下学习的过程。
从hello world开始
使用一个记事本或者其他别的随意什么文本编辑器都可以(我这里用的是vscode,装了powershell的插件,有语法提示,还挺好用),写上:
"hello world"
保存成 test.ps1,注意这里ps1后缀是powershell脚本的格式。
保存好后在当前目录打开powershell的窗口,就是那个蓝蓝的家伙,运行.\test.ps1,结果弹出提示:
.\test.ps1 : 无法加载文件 E:\myproject\powershell_script\test.ps1,因为在此系统上禁止运行脚本。
有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies
。
所在位置 行:1 字符: 1
+ .\test.ps1
+ ~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [],PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
这里无法直接运行脚本,为什么?这是因为Windows给p