标签: powershell-v7

警告原因:PowerShell 检测到您可能正在使用屏幕阅读器并出于兼容性目的禁用了 PSReadLine

脚步

在 Windows 10 上启动 PowerShell 7。

实际结果

PowerShell 7.0.0
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/powershell
Type 'help' to get help.

Warning: PowerShell detected that you might be using a screen reader and has disabled PSReadLine for compatibility purposes. If you want to re-enable it, run 'Import-Module PSReadLine'.
Run Code Online (Sandbox Code Playgroud)

预期结果

PowerShell 启动时不显示警告,因为我没有使用屏幕阅读器。

解决方法

运行指定的命令Import-Module PSReadLine。自从我第一次想了解为什么会出现警告以来,我就没有运行过它。

$PSVersionTable 输出:

Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.18362
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, …
Run Code Online (Sandbox Code Playgroud)

powershell powershell-v7

12
推荐指数
2
解决办法
8009
查看次数

无法使用 powershell 自定义日期从某个日期获得年数的差异?

我无法使用 Powershell 从某个日期获得时差,如下所示:

$Date = '11/12/2001'
(New-TimeSpan -Start (Get-Date -Date $Date) -End (Get-Date)).ToString("'yyyy' Years 'MM' Months 'dd' Days 'hh' Hours 'mm' Minutes 'ss' Seconds'")
Run Code Online (Sandbox Code Playgroud)

错误:

Exception calling "ToString" with "1" argument(s): "Input string was not in a correct format." 
At line:2 char:1 
+ (New-TimeSpan -Start (Get-Date -Date $Date) -End (Get-Date)).ToString ... 
Run Code Online (Sandbox Code Playgroud)

为什么我不能得到年和月的过去?

powershell powershell-v7

1
推荐指数
1
解决办法
93
查看次数

标签 统计

powershell ×2

powershell-v7 ×2