---
title: "PowerShell使用记录"
id: "2627"
type: "post"
slug: "powershell%e4%bd%bf%e7%94%a8%e8%ae%b0%e5%bd%95"
published_at: "2020-03-13T03:53:44+00:00"
modified_at: "2020-03-17T17:12:22+00:00"
url: "https://seq.ink/all/2627.html"
markdown_url: "https://seq.ink/all/2627.html.md"
excerpt: "先用管理员权限打开PowerShell 添加脚本执行权限 set-executionpolicy remotesigned -s currentuser 开启初始化PS(类似于Linux下的.bashrc文件) new-item -path ..."
taxonomy_category:
  - "ALL"
  - "Windows"
taxonomy_post_tag:
  - "PowerShell"
  - "Windows"
---

先用管理员权限打开PowerShell 添加脚本执行权限  
 `set-executionpolicy remotesigned -s currentuser`

开启初始化PS(类似于Linux下的.bashrc文件)  
 `new-item -path $profile -itemtype file -force`这句类似于创建.bashrc文件  
 `notepad $profile`用记事本编辑该文件

场景1：  
 初始化的时候将mysql环境变量加载进去，达到以后打开PS都能使用mysql命令的效果（持久化，不影响系统环境）

```
$env:Path="$env:Path;C:\xampp\mysql\bin"
```

将这句写入记事本打开的文件，以后都会在启动PS的时候初始这条命令。
