Export-Console 帮助信息

本文介绍如何使用Export-Console命令将当前控制台配置导出到文件以便后续使用或分享。文章详细解释了命令的语法、参数及用法,并通过实例演示了如何添加管理单元、导出配置以及使用导出的配置启动新会话。
 
如下说明是翻译: help Export-Console 产生的帮助信息.
译者: Edengundam(马涛)
 
Export-Console
 
摘要
将当前控制台配置导出到文件, 以便于重新使用或将其共享.
 
语法
Export-Console [[-path] <string>] [-force] [-noClobber] [-whatIf] [-confirm] [<CommonParameters>]
 
详细描述
Export-Console cmdlet将当前控制台配置导出到Windows PowerShell控制台文件(.psc1). 你可以使用此cmdlet保存你对属性进行的修改或者添加到控制台Windows PowerShell管理单元的配置信息.
 
参数
 
-path <string>
指定控制台文件(*.psc1)的路径名和文件名. 输入的路径名为可选项. 不允许使用通配符.
 
如果你只输入文件名, Export-Console在当前目录创建以 ".psc1"为文件扩展名的文件.
 
除非你在当前会话过程中已经导出过控制台信息, 否则必须指定此参数. 如果你指定NoClobber参数组织当前控制台文件被覆盖, 那么此参数也必须指定.
 
如果你忽略此参数, Export-Console将会覆盖(替换文件中的内容)此会话最近使用过的额控制台文件.
 
强制参数?
false
参数位置?
1
默认值
 
允许从管道绑定输入?
true (根据值, 根据属性名)
允许通配符扩展?
false
 
-force <SwitchParameter>
在不破坏安全性的前提下, 能够避免影响命令成功执行的限制条件. Force将在不给出警告的情况下允许你覆盖具有只读属性的文件. 文件只读属性将被取消, 并且在命令结束后也不会被重置.
 
强制参数?
false
参数位置?
named
默认值
 
允许从管道绑定输入?
false
允许通配符扩展?
false
 
-noClobber <SwitchParameter>
不覆盖(替换原有内容) 已经存在的文件. 默认情况下, 如果文件已经在指定路径存在, Export-Console 不提示任何警告, 将其覆盖.
 
强制参数?
false
参数位置?
named
默认值
 
允许从管道绑定输入?
false
允许通配符扩展?
false
 
-whatIf
描述执行此命令将会发生的现象, 不会真正执行此命令.
 
强制参数?
false
参数位置?
named
默认值
 
允许从管道绑定输入?
false
允许通配符扩展?
false
 
-confirm
执行命令前提示你进行确认.
 
强制参数?
false
参数位置?
named
默认值
 
允许从管道绑定输入?
false
允许通配符扩展?
false
 
<公共参数>
此命令支持公共参数: -Verbose, -Debug, -ErrorAction, -ErrorVariable, and -OutVariable. 更多信息, 输入, "get-help about_commonparameters".
 
输入类型
none
 
返回类型
FileInfo对象
 
注意
 
更多信息, 输入"Get-Help Export-Console -detailed". 需要技术信息, 输入"Get-Help Export-Console -full".
 
当前控制台文件的名称被自动的保存在$ConsoleFilename变量中. 如果此变量中没有值, 则当前控制台为Windows PowerShell的默认控制台.
 
要在一个新的会话中使用Windows PowerShell控制台文件, 使用下面的语法启动Windows PowerShell:
"powershell.exe -PsConsoleFile <ConsoleFile>.psc1".
 
关于你可以添加到控制台的Windows PowerShell管理单元信息(以及使用Export-Console进行保存), 输入"Get-Help About_PSSnapins"获得更多信息.
 
如果需要为该命令提供多个参数, 请使用逗号进行分隔. 例如, "<parameter-name> <value1>, <value2>".
 
1
 
C:/PS>export-console -path $pshome/Consoles/ConsoleS1.psc1
 
此命令将控制台配置导入到变量$pshome保存的目录位置的Console子目录中的ConsoleS1.psc1文件. 默认情况下, $pshome存储着Windows PowerShell的安装目录. 要查看你的计算机上此变量的值输入"$pshome".
 
2
 
C:/PS>export-console
 
此命令导出控制台配置到当前会话最近使用过的Windows PowerShell控制台文件, 此命令将会覆盖文件中已经存在的配置信息.
 
如果在当前会话中没有导出控制台文件, 你将会被提示是否继续处理并被要求输入文件名称.
 
3
 
C:/PS>add-pssnapin NewPSSnapIn
 
export-console -path NewPsSnapinConsole.psc1
 
powershell.exe -PsConsoleFile NewPsSnapinConsole.psc1
 
这些命令添加Windows PowerShell管理单元NewPsSnapin到当前控制台, 并将导出当前控制台配置, 最后使用新控制台配置启动Windows PowerShell会话.
 
第一个命令使用Add-PsSnapin cmdletNewPsSnapin管理单元添加到当前控制台. 你只能添加那些在你系统中注册的管理单元.
 
第二个命令将包含管理单元的控制台配置导出到NewPsSnapinConsole.psc1文件.
 
第三个命令使用NewPsSnapinConsole.psc1文件启动Windows PowerShell.
 
当你将Windows PowerShell管理单元添加到控制台时, 管理单元支持的提供程序和cmdlet立即可以被使用. 你不需要启动的新的会话. 然而, 管理单元仅仅被添加到当前控制台, 新会话将不会包括新添加的管理单元, 您可以通过导出当前控制台配置, 并在启动Windows PowerShell时指定该配置来允许新的管理单元依然可以使用.
 
4
 
C:/PS>export-console -path Console01
 
此命令将当前控制台配置导入到当前目录的Console01.psc1文件中. 此命令使用参数Path来指定控制台文件的名称. 默认情况下, Export-Console将会给文件名添加.psc1扩展名, 并在当前目录创建改文件.
 
5
 
C:/PS>export-console MyConsole
 
C:PS>$ConsoleFilename
 
这些命令将当前控制台配置导出到MyConsole.psc1文件中, 并使用变量$ConsoleFilename找到当前控制台文件的位置.
 
第一个命令使用Export-Console将当前控制台配置导出到当前目录下的MyConsole.psc1文件中. 它使用了参数Path, 由于此参数名是可选项, 所以这里将其省略.
 
第二命令使用变量$ConsoleFilename来找到当前控制台文件的名称:
 
C:/Test/MyConsole.psc1
 
相关链接
Add-PSSnapIn
Get-PSSnapIn
Remove-PSSnapIn
 
[plugin:vite-plugin-eslint] D:\物联网\src\views\SceneManagement\list\index.vue 6:14 warning Expected a linebreak before this attribute vue/first-attribute-linebreak 16:78 warning Attribute "v-if" should go before ":content" vue/attributes-order 19:39 warning Attribute "v-else" should go before "class" vue/attributes-order 36:23 warning Expected a linebreak before this attribute vue/first-attribute-linebreak 38:23 warning Expected a linebreak before this attribute vue/first-attribute-linebreak 41:19 warning Expected a linebreak before this attribute vue/first-attribute-linebreak 86:23 warning Expected a linebreak before this attribute vue/first-attribute-linebreak 88:23 warning Expected a linebreak before this attribute vue/first-attribute-linebreak 108:24 warning Expected a linebreak before this attribute vue/first-attribute-linebreak 122:27 warning Expected a linebreak before this attribute vue/first-attribute-linebreak 132:22 warning Expected a linebreak before this attribute vue/first-attribute-linebreak 136:26 warning Expected a linebreak before this attribute vue/first-attribute-linebreak 148:37 warning Expected a linebreak before this attribute vue/first-attribute-linebreak 151:30 warning Expected a linebreak before this attribute vue/first-attribute-linebreak 156:31 warning Expected a linebreak before this attribute vue/first-attribute-linebreak 169:14 warning Expected a linebreak before this attribute vue/first-attribute-linebreak 225:27 warning Expected a linebreak before this attribute vue/first-attribute-linebreak 228:24 warning Expected a linebreak before this attribute vue/first-attribute-linebreak 268:19 warning Expected a linebreak before this attribute vue/first-attribute-linebreak 282:14 warning Expected a linebreak before this attribute vue/first-attribute-linebreak 299:19 warning Expected a linebreak before this attribute vue/first-attribute-linebreak 322:20 warning Expected a linebreak before this attribute vue/first-attribute-linebreak 331:24 warning Expected a linebreak before this attribute vue/first-attribute-linebreak 349:23 warning Expected a linebreak before this attribute vue/first-attribute-linebreak 364:15 warning 'Dayjs' is defined but never used @typescript-eslint/no-unused-vars 365:96 warning 'GetIrCtrlCode' is defined but never used @typescript-eslint/no-unused-vars 365:128 warning 'sendDoorControls' is defined but never used @typescript-eslint/no-unused-vars 365:146 warning 'setAirConditionParams' is defined but never used @typescript-eslint/no-unused-vars 365:233 warning 'GetModelOutputItem' is defined but never used @typescript-eslint/no-unused-vars 372:8 warning 'D:\物联网\node_modules\@arco-design\web-vue\es\icon\index.d.ts' imported multiple times import/no-duplicates 374:3 warning 'IconCalendar' is defined but never used @typescript-eslint/no-unused-vars 375:3 warning 'IconHome' is defined but never used @typescript-eslint/no-unused-vars 376:3 warning 'IconLeft' is defined but never used @typescript-eslint/no-unused-vars 377:3 warning 'IconRight' is defined but never used @typescript-eslint/no-unused-vars 378:8 warning 'D:\物联网\node_modules\@arco-design\web-vue\es\icon\index.d.ts' imported multiple times import/no-duplicates 380:8 warning 'axios' is defined but never used @typescript-eslint/no-unused-vars 381:8 warning 'JsSHA' is defined but never used @typescript-eslint/no-unused-vars 382:10 warning 'generateEventConfig' is defined but never used @typescript-eslint/no-unused-vars 388:8 warning 'DateCell' is defined but never used @typescript-eslint/no-unused-vars 456:5 error The "OperationBar" component has been registered but not used vue/no-unused-components 601:14 warning 'getStatusText' is defined but never used @typescript-eslint/no-unused-vars 611:14 warning 'getPatternText' is defined but never used @typescript-eslint/no-unused-vars 621:14 warning 'getSpeedText' is defined but never used @typescript-eslint/no-unused-vars 651:14 warning 'getControlText' is defined but never used @typescript-eslint/no-unused-vars 660:14 warning 'getDeviceNameByDoorId' is defined but never used @typescript-eslint/no-unused-vars 1064:13 warning Unexpected console statement no-console 1186:9 warning Unexpected console statement no-console 1188:9 warning Unexpected console statement no-console 1234:9 warning Unexpected console statement no-console 1266:9 warning Unexpected console statement no-console 1269:9 warning Unexpected console statement no-console 1304:7 warning Unexpected console statement no-console 1305:7 warning Unexpected console statement no-console 1308:9 warning Unexpected console statement no-console 1343:15 warning Unexpected console statement no-console 1410:7 warning Unexpected console statement no-console 1419:11 warning Unexpected console statement no-console 1426:11 warning Unexpected console statement no-console 1432:11 warning Unexpected console statement no-console 1437:7 warning Unexpected console statement no-console 1536:15 warning Unexpected console statement no-console 1642:9 warning Unexpected console statement no-console 1644:9 warning Unexpected console statement no-console 1668:13 warning Unexpected console statement no-console 1801:7 warning Unexpected console statement no-console 1803:7 warning Unexpected console statement no-console 1804:7 warning Unexpected console statement no-console 1809:9 warning Unexpected console statement no-console 1813:9 warning Unexpected console statement no-console 1838:14 warning 'fillDetailFormFromChannelList' is defined but never used @typescript-eslint/no-unused-vars 1906:7 warning Unexpected console statement no-console 1917:11 warning 'sendControl' is assigned a value but never used @typescript-eslint/no-unused-vars 1953:7 warning Unexpected console statement no-console 1968:9 warning Unexpected console statement no-console 1970:9 warning Unexpected console statement no-console 2062:9 warning Unexpected console statement no-console 2064:9 warning Unexpected console statement no-console 2068:9 warning Unexpected console statement no-console 2070:9 warning Unexpected console statement no-console 2091:9 warning Unexpected console statement no-console 2092:9 warning Unexpected console statement no-console 2095:9 warning Unexpected console statement no-console 2096:9 warning Unexpected console statement no-console 2102:9 warning Unexpected console statement no-console 2122:13 warning Unexpected console statement no-console 2126:11 warning Unexpected console statement no-console 2134:11 warning Unexpected console statement no-console 2138:9 warning Unexpected console statement no-console 2145:9 warning Unexpected console statement no-console 2146:9 warning Unexpected console statement no-console 2149:9 warning Unexpected console statement no-console 2150:9 warning Unexpected console statement no-console 2154:9 warning Unexpected console statement no-console 2156:9 warning Unexpected console statement no-console 2231:7 warning Unexpected console statement no-console 2258:9 warning Unexpected console statement no-console 2259:9 warning Unexpected console statement no-console 2356:7 warning Unexpected console statement no-console 2360:7 warning Unexpected console statement no-console ✖ 99 problems (1 error, 98 warnings) 0 errors and 25 warnings potentially fixable with the `--fix` option. D:/物联网/src/views/SceneManagement/list/index.vue at formatError (file:///D:/%E7%89%A9%E8%81%94%E7%BD%91/node_modules/vite/dist/node/chunks/dep-3e87c7b2.js:40359:46) at TransformContext.error (file:///D:/%E7%89%A9%E8%81%94%E7%BD%91/node_modules/vite/dist/node/chunks/dep-3e87c7b2.js:40355:19) at TransformContext.transform (D:\物联网\node_modules\vite-plugin-eslint\dist\index.js:1:2469) at async Object.transform (file:///D:/%E7%89%A9%E8%81%94%E7%BD%91/node_modules/vite/dist/node/chunks/dep-3e87c7b2.js:40612:30) at async loadAndTransform (file:///D:/%E7%89%A9%E8%81%94%E7%BD%91/node_modules/vite/dist/node/chunks/dep-3e87c7b2.js:36998:29 Click outside or fix the code to dismiss. You can also disable this overlay by setting server.hmr.overlay to false in vite.config.js.
09-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值