This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1. | |
| download WSL | |
| 2.download subsys for WSL | |
| (ubuntu) | |
| PS. | |
| you can use the linux directory | |
| cd /home | |
| you can use linux to download system software(nginx...) | |
| sudo install nginx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 以下是一些常用的 Linux 命令,这些命令可以帮助你在 Linux 系统中进行文件管理、系统监控、网络配置等操作。 | |
| ### 文件和目录管理 | |
| 1. **`ls`** — 列出目录内容 | |
| - `ls`:列出当前目录的文件和子目录。 | |
| - `ls -l`:列出详细信息(权限、所有者、大小、修改日期等)。 | |
| - `ls -a`:显示所有文件(包括隐藏文件)。 | |
| 2. **`cd`** — 改变目录 | |
| - `cd /path/to/directory`:切换到指定目录。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $Destination = "$home\links\$title.lnk" | |
| $sourcepath =$url | |
| $WshShell = New-Object -comObject WScript.Shell | |
| $Shortcut = $WshShell.CreateShortcut("$Destination") | |
| $Shortcut.TargetPath = $sourcepath |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #获取环境变量 | |
| $pspath=[System.Environment]::GetEnvironmentVariable('psModulepath','machine') | |
| #添加环境变量 | |
| $pspath+=";$home\modules" | |
| #设置环境变量 | |
| [System.Environment]::SetEnvironmentVariable('psmodulepath',$pspath,'machine') | |
| #系统环境变量和用户环境变量的区别 | |
| 系统环境变量: 'machine' | |
| 当前用户环境变量:'User' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1.parameterset | |
| nction Measure-Lines { | |
| [CmdletBinding(DefaultParameterSetName = 'Path')] | |
| param ( | |
| [Parameter(Mandatory, ParameterSetName = 'Path', Position = 0)] | |
| [Parameter(Mandatory, ParameterSetName = 'PathAll', Position = 0)] | |
| [string[]]$Path, | |
| [Parameter(Mandatory, ParameterSetName = 'LiteralPathAll', ValueFromPipeline)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| windowS常见encoding:有 cp936,UTF-8 | |
| 确保你和来源字体编码相同 | |
| powershell一般使用的是utf-8,确保你来源和终端encoding相同即可 | |
| 如果来源JavaScript 可以用 | |
| iconv-lite 模组进行encoding 转码 | |
| 实例: | |
| cp936:utf-8 | |
| const { exec } = require('node:child_process'); | |
| const path = require('node:path'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1.via bat: | |
| const { exec, spawn } = require('node:child_process'); | |
| exec('my.bat', (err, stdout, stderr) => { | |
| if (err) { | |
| console.error(err); | |
| return; | |
| } | |
| console.log(stdout); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1.The ValidateSet attribute specifies a set of valid values for a parameter or variable and enables tab completion. PowerShell generates an error if a parameter or variable value doesn't match a value in the set. In the following example, the value of the Fruit parameter can only be Apple, Banana, or Pear. | |
| [ValidateSet('Apple', 'Banana', 'Pear')] | |
| 2.You can use a Class to dynamically generate the values for ValidateSet at runtime. In the following example, the valid values for the variable $Sound are generated via a Class named SoundNames that checks three filesystem paths for available sound files: | |
| Class SoundNames : System.Management.Automation.IValidateSetValuesGenerator { | |
| [string[]] GetValidValues() { | |
| $SoundPaths = '/System/Library/Sounds/', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Parameter( | |
| Position = 0, | |
| ValueFromPipeline = true, | |
| ValueFromPipelineByPropertyName = true)] | |
| [ValidateNotNullOrEmpty] | |
| public string[] Name | |
| { | |
| get { return this.processNames; } | |
| set { this.processNames = value; } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 获取系统环境变量 PATH 并将其拆分为数组 | |
| $pathArray = $env:PATH -split ';' | |
| # 输出数组内容 | |
| $pathArray |