问题标签 [powershell-v5.1]
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.
powershell - 如何在 PowerShell 上启用 cmdlet 参数自动完成弹出窗口?
所以我在这里关注这个初学者 PowerShell 教程,并关注显示如何启用在尝试查看特定 cmdlet 的所有可能参数时出现的自动建议弹出窗口。因此,根据文章,当我尝试通过在 cmdlet 后键入“-”来复制它时,应该会出现一个弹出窗口,显示 cmdlet 的所有可能参数。但对我来说,这似乎不起作用——尽管它确实以特定格式出现,但只有在我输入 ctrl+space 之后才会出现。
有没有办法让参数以弹出格式自动出现?
所以这里是文章如何显示自动建议弹出窗口:
这是我的 PowerShell,我必须在其中输入 ctrl+space,但参数以不同的格式显示:
注意我使用的是 PowerShell 5.1。
registry - Set-ItemProperty 忽略尾随 .
使用 Powershell 5.1,我正在尝试在以下位置创建注册表值:(
HKLM:\SOFTWARE\Classes\.
注意尾随句点)
不幸的是Set-ItemProperty似乎忽略了尾随 . 并在: 下创建值
HKLM:\SOFTWARE\Classes
。
我以管理员身份运行 Powershell ISE,并测试了各种引号、路径和 LiteralPath、反引号转义和尾随 / 无济于事。
我已经在不同的键下尝试了以下内容,以防类有什么奇怪的......
但输出显示它忽略了 . 除非从字面上逃脱(当它创建一个带有反引号的键时......
请问我错过了什么?
azure-data-factory-2 - 从 Azure 数据工厂日志中提取数据
我正在检索 Azure 数据工厂日志以使用 Powershell 进行分析。
我正在成功检索顶级日志(管道)和嵌套在其中的日志(活动)并写入文本文件。
但是,我在展平活动文件时遇到问题,该文件由平面记录和包含 json 的字段组成
这是我的删节脚本。问题在于最后一个 cmdlet 调用。我需要弄清楚如何将其展平为我需要的
在上面$oADFSubLog
的脚本中,我发现我可以像这样提取一些我需要的部分:
(ConvertFrom-Json -InputObject $oADFSubLog[0].Input.ToString()).packageLocation
这会将我需要的属性从 Json 中提取出来
但我不确定如何轻松地将其与其他平面属性一起推送到文件中
我试过这个,这真的只是在黑暗中刺伤
但我明白了
Select-Object : 无法将 System.Management.Automation.PSObject 转换为以下类型之一 {System.String, System.Management.Automation.ScriptBlock}。
我已经看到了一些可以添加的自定义 cmdlet 和脚本的示例,但我还不想去那里 - 我只想了解如何执行此操作。
powershell - 无法将“-persist”添加到 New-PSDrive - 出现错误“网络资源类型不正确”
正如标题所说,如果我尝试添加-persist
到 cmdlt,它会返回一个错误:
New-PSDrive : The network resource type is not correct
At line:1 char:1
+ New-PSDrive -Name P -Root <redacted> ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (P:PSDriveInfo) [New-PSDrive], Win32Exception
+ FullyQualifiedErrorId : CouldNotMapNetworkDrive,Microsoft.PowerShell.Commands.NewPSDriveCommand
作为参考,这是 PowerShell 中的管理员会话,但如果我在常规用户会话中执行此操作,我会得到完全相同的响应:
从一开始:我验证我想要使用的驱动器号可用(P,在这种情况下)
然后我尝试运行:(我已经将$locale
变量定义为,例如'\\foo\bar\'
)。
快乐的时光。这样可行。但当然,它对 Windows 资源管理器是不可见的,因为它只是在这个 PS 会话中。所以,我销毁它remove-psdrive P
(get-psdrive
-persist
它失败了。对于上下文,我这样做是为了可以使用带有远程 PSDrive 的 RoboCopy 编写脚本(我们想要使用 robocopy,因为它内置了报告、属性管理以及在目标位置维护文件结构的能力,我们想要使用PSDrives,因此我们可以为目标驱动器指定凭据)。
有没有人有任何想法?
编辑:哦,伙计……我不敢相信……但是以防万一其他人发现这个,我要离开它。问题是我路径的尾随\
。我删除了它,它仍然很好。
powershell - Powershell v5.1 Invoke-RestMethod 和绕过代理
我目前在 Powershell V5.1 中,想在 Invoke-RestMethod 命令上绕过 Internet Explorer 代理。
在 Powershell V6 中,有 -NoProxy 选项指示 cmdlet 将不使用代理来到达目标。这是绕过 Internet Explorer 中配置的代理,这正是我想要做的。
在 Powershell V6 中,代码类似于:
V5.1 中的任何解决方法?
谢谢,菲利普
internet-explorer-11 - 在 Powershell 中通过其 COM 对象浏览 IE
我编写了一个 Powershell 脚本来使用 IE 自动化 Web UI 测试。当我从 PowerShell 执行脚本时,该脚本运行良好。但是,我遇到了一个晦涩的问题,那就是当我Web UI test
从另一个 powershell 脚本运行我的脚本时,它失败了。我尝试调试它,发现它在以下行失败。
$button = $ie.Document.getElementsByTagName("button")
$button.Item().Click()
# $button.Item() 当脚本从另一个脚本执行时计算为空。
谁能帮我解决这个问题?看来,当我运行脚本时,该脚本在定位元素时没有问题,但是当它从另一个脚本运行时,无法找到我正在寻找的元素。
编辑 当我通过任务计划程序运行 PS 脚本时,我得到了同样的错误。该脚本仅在我直接调用它时才有效。如果我通过另一个脚本/程序调用,它不起作用。
powershell - Get-ChildItem and wildcards and filtering
I have two different ways of getting files with a wildcard pattern:
and
I prefer to use the latter instead of the former because the former (Get-ChildItem "$ActivityLogDirectory/*.csv"
) has, on occasion, given me a permission denied error.
They both appear to return the same results, but when I try to compress the resulting files with this command:
the former succeeds while the latter fails with the following error:
So what's the difference between these two ways of getting a listing of files using wildcards? Or perhaps asked another way, why does using -Filter *.csv
cause the Compress-Archive
cmdlet to fail?
powershell - 在字符串替换中使用变量 - Windows powershell
我有一个要求,我的字符串格式如下:
我在 TFS 2017 构建模板中使用以下 powershell 脚本来替换内部版本号值:
这给出了<?define BuildNumber = " 27994 " ?>
不正确的输出,因为我不希望值中有空格。当我尝试使用下面的代码时,它不起作用。
输出 :<?define $27994 ?>
我尝试了所有组合,但无法让报价正常工作。请提出解决方案。
powershell - Run a external program with parameters and wait for it to end in Powershell
Actually, I've found so many solutions to this question, but none works. The program I'd like to run in Powershell is Reaper - a Digital Audio Workstation, and I'm going to use its command line tool for batch-processing audio files within a PS script. The code related to Reaper is as below:
I'm going to use the Start-Process
with -wait
parameter to allow my script to wait for it to end then go on to the next line of code which is a Rename-Item
function.
If PS doesn't wait for the process to finish, then the next line would throw an error, something like "no such file was found in the directory".
The suggestions I've found are here, here, and here. But none of those work. The problem is that Reaper doesn't accept the argument to be added separately as:
or:
or:
It can only work without a problem as a whole block like the first code line above. So what can I do now?