问题标签 [powershell-ise]

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 投票
3 回答
1704 浏览

powershell - PowerShell 2 CTP3 ISE 的自定义读取主机对话框

是否可以将自定义对话框挂接到新的 PowerShell ISE(集成脚本环境)中,以替换现有的 .NET WinForms 对话框。我说的是Read-Hostcmdlet 启动以请求用户输入的对话框。

0 投票
2 回答
2557 浏览

xml - 为什么 XDocument.Descendants() 在 PowerShell ISE 中返回 IEnumerator?

我正在编写一个 PowerShell 脚本来操作一些 Windows Installer XML (WiX)。我正在使用 .NET 3.5 中的新 XML API 来执行此操作,因为我发现它比 DOM 更易于使用。以下脚本片段断然拒绝工作:

该脚本在单独的行上输出每个 <String> 标记。一旦这个错误被解决,我将让它做一些更有趣的事情;-)

XML 文档是一个标准的 WiX 本地化文件:

$strings 不是 $null(我已经明确测试过),如果我写主机 $wxl,我可以看到文档已经加载。将 $strings 导入 Get-Member 会返回一个错误,指出“没有为 get-member 指定对象”并且 write-host $strings 什么也不做。我也试过 $wxl.Descendants("WixLocalization") 得到相同的结果。$wxl.Root 和 $wxl.Nodes 之类的东西按预期工作。使用 PowerShell ISE 进行调试,我看到 $strings 已设置为 IEnumerator,而不是预期的 IEnumerable<XElement>。使用单个 MoveNext 和 Current 测试 IEnumerator 指示“Current =”,大概是 $null。

奇怪的是,相同的技术在以前的脚本中也有效。完全相同的代码,但具有不同的变量名和字符串文字。并且刚刚尝试调试该脚本(以验证行为),它现在似乎也显示相同的行为。

0 投票
1 回答
340 浏览

powershell - Tabexpansion 函数不解析变量

我正在尝试覆盖并实现我自己的 TabExpansion。在函数中,当某个 $lastword 条件匹配时,我想解析 $psise.CurrentFile.Editor.Text 的内容。我遇到的问题是变量 $psise.CurrentFile.Editor.Text 被解析为我的 TabExpansion 函数的内容,而不是 PowerShell ISE 选项卡中的任何文本。

这是简单的测试功能。打开 ISE 选项卡并粘贴以下 tabexpansion 函数定义:

在 ISE 中运行脚本。接下来在 ISE 中打开另一个选项卡,输入一些文本并按 Tab 键输出将是

而不是第二个选项卡中的任何文本。在 tabexpansion 函数中使用时,有什么方法可以让 $psise.CurrentFile.Editor.Text 在运行时解析?

0 投票
1 回答
1661 浏览

powershell - Powershell 2 ISE,不在导入模块中的断点处停止

当我们在导入的模块中设置断点时,调试器会忽略断点。有没有其他人看到过这种行为?
这让我抓狂,我们广泛使用 PowerShell 模块。
真正奇怪的是,如果我运行 get-psbreakpoint,我可以看到断点

编辑:如果我删除 psd1(清单文件)似乎可以工作

0 投票
1 回答
4023 浏览

forms - Windows Forms look different in Powershell and Powershell ISE. Why?

I have written a script which is basically a small wysiwyg signature generator for Outlook. We want our signatures to be in corporate colours, and semi-standardised - hence the requirement for this.

I did the development work in Powershell ISE and all looked good. However, when I run the script just using powershell (as the users will) it looks totally different:

Powershell vs Powershell ISE http://www.freeimagehosting.net/uploads/1d6e6c5c6f.png

The top one was generated in ISE, and looks as I want it. The bottom one was run from powershell directly and seems to have visually regressed five years!

How can I get the script to look as snazzy in Powershell as it does in Powershell ISE?

Thanks,

Ben

0 投票
1 回答
1271 浏览

powershell - 控制台 Powershell 中的 $psise 对象

可以在控制台中加载 $psise 对象吗?我想在 ISE 中打开几个文件,但在做

只打开第一个。在 ISE 内部我没有这个问题,因为我使用 $psise 对象打开文件

0 投票
2 回答
1032 浏览

powershell - 如何让 Powershell-ISE 发布 Cmdlet DLL

我正在开发一个 Cmdlet 并使用 Powershell-ISE 进行测试。ISE 将我的 DLL 锁定并防止重新构建然后重新加载。

我试过调用 remove ps-snappin,但 DLL 仍然锁定。

0 投票
1 回答
1479 浏览

sharepoint - 将自定义 Web 模板应用于站点集合适用于 powershell ise,而不适用于 powershell 控制台

我正在开发一个用于部署共享点项目的自动化脚本。我正在使用创建站点时必须应用的沙盒级 web 模板。这样做我遇到了很多麻烦,因为似乎 sharepoint 缓存了 webtemplates 列表,而 get-spwebtemplate 找不到新添加的列表。我使它工作的方式是这样的:

如您所见,我使用的是 .net sharepoint api 而不是 cmdlet。这在 PowerShell ISE 中很有效,但在 PowerShell 控制台中它会引发有关引用的 DLL 的异常:

使用“1”参数调用“ApplyWebTemplate”的异常:“无法加载文件或程序集 'XXX.SharePoint.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=534c125b45123456' 或其依赖项之一。系统找不到指定的文件。” 在 C:\Build\SharePointBuild.p s1:318 char:37 + $site.OpenWeb().ApplyWebTemplate <<<< ($web_template_name) + CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordE xception + FullyQualifiedErrorId : DotNetMethodException

在站点集合中安装 Web 模板沙盒解决方案时,程序集已在 GAC 中完美注册。

有任何想法吗?谢谢!

0 投票
3 回答
16481 浏览

powershell - 为什么 PowerShell ISE 不允许我在以管理员身份运行时设置断点?

由于未能让 PowerGUI 正常工作,我转而使用 PowerShell ISE。但是,如果我以管理员身份运行它,它不会让我设置任何断点。

如果我正常启动(我的登录名是管理员的成员)一切都很好,但是因为我需要编写一些需要完全管理员权限的任务,所以这不好。

我已将脚本保存为正确的文件(即它不是“untitled1.ps1”),但没有任何乐趣。

我正在运行 Windows 7 x64 Ultimate。

奇怪的是,这在我的 Windows 2008 R2 开发盒上似乎不是问题(我以管理员成员身份登录,然后运行 ​​PS ISE“作为管理员”并设置并命中断点。

任何想法为什么会这样?

0 投票
5 回答
75326 浏览

powershell - 如何将所需的参数传递给 Powershell ISE 中的脚本?

见标题。

我在脚本的头部指定了所需的参数:

当我想使用 Powershell ISE 调试脚本时:如何填写这些参数?