# 介绍
TIP
officialsite
介绍 powershell 的基础使用
# 环境构建
多年来,PowerShell 已有很多版本发布。 最初,Windows PowerShell 是在 最初 .NET Framework 基础之上构建而成,
仅适用于 Windows 系统。 在最新版本中,PowerShell 使用 新版 .NET Core 3.1 作为运行时。
PowerShell 在Windows、macOS 和 Linux平台上运行。
# 基础知识整理
查看版本
$PSVersionTable.PSVersion特性介绍
- 命令行输入
命令的关键字使用tab和shift+tab实现自动代码提示
- 命令行输入
语法介绍
实参均支持通配符:
*等其他符号#具体的参考 $help about_wildcards接受参数均以
-开始$get-help get-service -full-ShowWindow用于单独弹窗显示帮助内容get-alias显示内置的函数 abbr 写法使用分号
;执行多个语句命令$cls ; cd E:
查看帮助文档
#help,get-help都是可以的 $help #更方便并且可以支持搜索 #支持搜索的通配符例如:* $get-help xx*xx* #查看帮助文档信息 $get-help -full/-detailed/-examples #在新的窗口里查看文档 [ShowWindow] $get-help get-service -ShowWindow #查看about的文档基于powershell的构建信息 $help about_* #匹配查询所有的主题 $help about_xxxx#查看主题内容
# 其他命令操作
管道
pipline操作符|#实现简单的对象引用 #导出信息到csv $get-help get-service M* | export service.csv-whatif获取执行命令产生的结果,和管道|一起使用,作为执行命令时的提示$get-service M* -whatif/-confirm
# 配置主题
1.基本设置参考
官方配置参考
cnBlog
2.主题文件获取
链接 1
链接 2
3.基础示例参考
schemes:写入样式配置的地方
colorScheme:xxx这个是对应的窗口应用哪一个样式配置
// This file was initially generated by Windows Terminal 1.0.1811.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
// You can add more global application settings here.
// To learn more about global settings, visit https://aka.ms/terminal-global-settings
"theme": "dark",
"launchMode": "fullscreen",
// If enabled, selections are automatically copied to your clipboard.
"copyOnSelect": true,
// If enabled, formatted data is also copied to your clipboard
"copyFormatting": false,
// A profile specifies a command to execute paired with information about how it should look and feel.
// Each one of them will appear in the 'New Tab' dropdown,
// and can be invoked from the commandline with `wt.exe -p xxx`
// To learn more about profiles, visit https://aka.ms/terminal-profile-settings
"profiles": {
"defaults": {
// Put settings here that you want to apply to all profiles.
"fontFace": "Cascadia Code PL"
},
"list": [
{
// Make changes here to the powershell.exe profile.
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false,
"startingDirectory": "./",
"colorScheme": "AdventureTime"
},
{
// Make changes here to the cmd.exe profile.
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "命令提示符",
"commandline": "cmd.exe",
"hidden": false
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
}
]
},
// Add custom color schemes to this array.
// To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
"schemes": [
{
"name": "AdventureTime",
"black": "#050404",
"red": "#bd0013",
"green": "#4ab118",
"yellow": "#e7741e",
"blue": "#0f4ac6",
"purple": "#665993",
"cyan": "#70a598",
"white": "#f8dcc0",
"brightBlack": "#4e7cbf",
"brightRed": "#fc5f5a",
"brightGreen": "#9eff6e",
"brightYellow": "#efc11a",
"brightBlue": "#1997c6",
"brightPurple": "#9b5953",
"brightCyan": "#c8faf4",
"brightWhite": "#f6f5fb",
"background": "#1f1d45",
"foreground": "#f8dcc0"
},
{
"name": "lwz_solarized_light",
"black": "#073642",
"red": "#dc322f",
"green": "#ffe79e",
"yellow": "#b58900",
"blue": "#268bd2",
"purple": "#d33682",
"cyan": "#2aa198",
"white": "#eee8d5",
"brightBlack": "#002b36",
"brightRed": "#cb4b16",
"brightGreen": "#00bc00",
"brightYellow": "#657b83",
"brightBlue": "#949800",
"brightPurple": "#6c71c4",
"brightCyan": "#93a1a1",
"brightWhite": "#fdf6e3",
"background": "#ffffff",
"foreground": "#000000",
"selectionBackground": "#bfbfbf"
}
],
// Add custom keybindings to this array.
// To unbind a key combination from your defaults.json, set the command to "unbound".
// To learn more about keybindings, visit https://aka.ms/terminal-keybindings
"keybindings": [
// Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
// These two lines additionally bind them to Ctrl+C and Ctrl+V.
// To learn more about selection, visit https://aka.ms/terminal-selection
{ "command": { "action": "copy", "singleLine": false }, "keys": "ctrl+c" },
{ "command": "paste", "keys": "ctrl+v" },
// Press Ctrl+Shift+F to open the search box
{ "command": "find", "keys": "ctrl+shift+f" },
// Press Alt+Shift+D to open a new pane.
// - "split": "auto" makes this pane open in the direction that provides the most surface area.
// - "splitMode": "duplicate" makes the new pane use the focused pane's profile.
// To learn more about panes, visit https://aka.ms/terminal-panes
{
"command": {
"action": "splitPane",
"split": "auto",
"splitMode": "duplicate"
},
"keys": "alt+shift+d"
}
]
}