问题标签 [powershell-core]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
564 浏览

powershell - 如何让“pwsh -c {...}”在Ubuntu上通过powershell命令的表达式结果?

在我的 Ubuntu 16 服务器上的 PHP 脚本中,我希望能够检查 Powershell 是否安装了某个模块,我尝试通过以下方式进行操作

但是即使模块没有安装,这一行也会返回 1。我想这是因为pwsh返回true独立于 powershell 命令的结果,表示该命令正确执行。有没有办法让我pwsh通过结果?

0 投票
1 回答
391 浏览

powershell - Linux 到 Windows - 远程执行 .exe

我们需要从 Linux 机器到 Windows 10 远程执行带有参数的 .exe。所以我们在 CentOS 中安装了 PowerShell。以下是我们使用的命令:

收到以下错误

Invoke-Command:无法使用指定的命名参数解析参数集。发出的一个或多个参数不能一起使用或提供的参数数量不足。
在行:1 字符:1

在此处输入图像描述

同样适用于 Windows 到 Windows。

0 投票
1 回答
261 浏览

powershell - PowerShell Core 添加内容字节失败

我正在使用 PowerShell Core v6.0.2,并尝试将字节数组写入文件。这在常规 PowerShell 中运行良好,但在 PowerShell Core 中失败

错误:

在此处输入图像描述

这是一个错误还是由于二进制排序问题而不能再使用 Byte ?

0 投票
1 回答
779 浏览

powershell - 为什么 Get-CimInstance CIM_LogicalDisk 返回两种类型?

为什么Get-CimInstance CIM_LogicalDisk同时返回 aWin32_LogicalDisk和 a Win32_MappedLogicalDisk

有一个 Win32_MappedLogical 磁盘 CIM 类,但没有 Cim_MappedLogicalDisk` 类。应该有吗?

在 pwsh 6 中似乎也没有。Linux 上的 pwsh 6 中没有 CIM cmdlet。CIM 是 Microsoft 独有的吗?我以为不是。

0 投票
1 回答
45 浏览

powershell - 删除 HTML 中的区域

我想在 HTML 中删除一个自我强加的区域。我已经制定了正确的正则表达式,我已经在Expresso中证明了这一点,并且正确的部分被突出显示。

快递

我在多行模式下运行它,并将此设置设置为 PowerShell 正则表达式字符串

遗憾的是,尽管该文件已被触及,但该区域并未被删除。

0 投票
2 回答
1152 浏览

powershell - Powershell 'x 或 y' 赋值

有几种语言提供默认或逻辑或分配机制:

到目前为止,我在 Powershell Core 中发现的唯一等价物是非常冗长的:

在某些情况下必须成为

有没有更好的选择 [edit:] 不会牺牲可读性?

0 投票
4 回答
5947 浏览

macos - “Install-Module -name AzureAD”在使用 MacOSX 的 PS6 上失败并出现错误

我能够在 MacOSX 上安装 Powershell Core,现在我正尝试从该实例管理 Azure AD 实例。

安装 AzureAD 模块时,出现以下错误

我四处寻找在 Mac 上安装 api-ms-win-core-sysinfo 的方法,但由于它是不同的操作系统,我没有看到任何直接的解决方案。

0 投票
1 回答
421 浏览

powershell - Can I customise the 'not recognized as the name of a cmdlet' error in Powershell?

Say I make a typo on the command line:

Powershell returns:

The long message is useful for scripts, but for interactive shell use, I'd like to wrap it with something shorter, like:

Can I wrap the error and change it to something shorter?

0 投票
2 回答
2652 浏览

powershell-core - 多部分表单脚本在 PowerShell 中完美运行,但在 PowerShell 核心中无法运行

以下代码在 Windows Server 上的 PowerShell 中完美运行

但是当我在 Mac 上的 PowerShell 核心中运行时,我收到以下错误:

知道这里有什么问题吗?非常感谢提前。

0 投票
1 回答
1367 浏览

comobject - 使用 PowerShell Core for Mac 加载带有宏的 .xls 文件

我正在尝试使用 PowerShell Core for Mac 加载 Excel 文件,但遇到New-Object. 它在第一行就失败了

这是我收到的错误消息:

有没有人遇到过这个问题,有人知道如何解决吗?