cost 111 ms
PowerShell 当 Where-Object 返回一项时,数组列表分配和 Where-Object 失败。 适用于 2 个以上的项目 - PowerShell Array list assignment and Where-Object fails when Where-Object returns one item. Works with 2+ items

长期搜索者,第一次张贴者。 :-) 将数组列表传递给 Where-Object 并将其分配回另一个数组列表时,如果 Where-Object 的结果是单个项目,则会生成转换错误。 但是当返回两个或多个项目时,相同的命令会成功。 这是 PowerShell 错误还是我遗漏了什么? 为什么会失败? 但 ...

如何使用 PowerShell 脚本运行 Terraform CLI 并传递映射类型的变量? - How can use a PowerShell script to run the Terraform CLI and pass a variable of type map?

Terraform 文件 ( infrastructure.tf ) 中的变量声明如下: 这是使用plan命令执行terraform命令行程序的 PowerShell 代码: Write-Host命令的输出是: 如果我将其复制粘贴到交互式 PowerShell 7.2 ( pwsh ) 会话中 ...

不同的 PowerShell colors 不同的 Windows 终端配置文件(浅色和深色) - Different PowerShell colors for different Windows Terminal profiles (light and dark)

我有两个不同的 Windows PowerShell Core 终端配置文件——一个采用深色方案,一种采用浅色方案。 这通常效果很好,除了在运行dir的常见情况下。 请注意,例如,文件夹名称的 colors 使名称在浅色主题 window 的情况下难以阅读。 我试图在两个版本中都正确着色。 我 ...

定期作业以查找具有与最近删除的用户相对应的标签的资源组 - Periodic job to find resource groups with tags corresponding to recently deleted users

我们有一个标签策略,每个资源组都有一个Tech-Owner-Email和Tech-Owner-Name标签。 我们希望在离开组织的人名下有资源组时收到通知。 找到属于最近离开的人的群组的好方法是什么? 我们希望这个过程定期运行并通知我们任何结果(电子邮件、团队、任何有效的) ...

Get-Package - PS CORE 不再提供已安装的软件 - Get-Package - PS CORE no longer provides installed software

我正在移动 yaml 管道,因此它使用 PS Core。 其中一个步骤是解析当前安装的软件并在存在时将其卸载: 但是,似乎新的 Get-Package - 不再提供已安装的软件。 有没有办法在新的 PS 7+ 中使用本机 cmdlet(不是 CMI/WMI [wmi 已弃用?])来实现这一点? ...

为什么要命令; ls -l file_doesnot_exists > /dev/null 2>&1 正在工作; ls -l 2>&1 file_doesnot_exists > /dev/null 不是 - why the command; ls -l file_doesnot_exists > /dev/null 2>&1 is working while; ls -l 2>&1 file_doesnot_exists > /dev/null is not

我只是想知道如何知道我们通常将哪个指令放在 shell 命令中? 例如,为什么命令: ls -l file_doesnot_exists > /dev/null 2>&1 正在工作,而此命令: ls -l 2>&1 file_doesnot_exists > ...

我有一个 function ,它返回一个具有特定命名属性的 PSCustomObject 。 如何让这些命名属性出现在自动完成中? - I have a function that returns a PSCustomObject with specific named properties. How can I get these named properties to appear in autocomplete?

这是一个简单的 function ,它将文件路径拆分为各个组件并将它们分配给一些属性: 然后我像这样使用 function: 我真正需要完成的是以某种方式为返回的 object 及其重要属性启用自动完成功能。 下面这张图正是我想要的: 我能够通过定义自定义 types.ps1xml 文件并使用与 ...

pwsh 7 格式默认:无法将“MySql.Data.Types.MySqlDateTime”类型的 object 转换为“System.IFormattable”类型 - pwsh 7 format-default: Unable to cast object of type 'MySql.Data.Types.MySqlDateTime' to type 'System.IFormattable'

我需要使用 pwsh 7 从 mysql 数据库中读取数据。在 powershell 5 上它工作正常,但使用 pwsh 7 时没有,并且在查询带有“时间戳”数据的表时收到错误消息: “格式默认:无法将“MySql.Data.Types.MySqlDateTime”类型的 object 转换为“S ...

Powershell:将 JSON 对象数组减少为单个 object 字段数组 - Powershell: Reduce an array of JSON objects to an array of a single object field

在 Powershell 中,如何将 JSON 对象数组(如下所示)简化为“名称”的简单字符串数组? 我没有遇到普通 Json-Object(非数组)的这个问题。 进入这个: 这是我想要做的。 此代码不返回数组; 相反,它返回数组中第一项的值。 与此相同的结果: ...


 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM