问题标签 [powershell-1.0]
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 脚本参数复制到局部变量?
我有一个非常简单的 Powershell v1.0 脚本来按名称杀死进程:
哪个有效。然而,当我刚刚
它不会找到任何进程。那么为什么需要将参数复制到局部变量中才能使代码正常工作呢?
xml - PowerShell:检索特定的内部 XML 元素
我有一个具有这种结构的 XML 文档:
<Fruit>
在 PowerShell 1 代码中通过其代码(或任何其他字段)获取元素的最佳方法是什么?(不是 XPath,因为它仅在 PowerShell 2 中受支持)
谢谢!
powershell - Powershell 1.0 - Renaming files fails when script is in a different directory
I am trying to batch rename old log files, but the script only works for me when the script is stored in the same folder as the log files. Here is the code:
When I run this script from E:\logs
, it works just fine. However, when I run this script from C:\Scripts, it gives me this error:
I also tried using the Move-Item
command with the -literalpath
switch but had the same result
powershell - Powershell 1.0 中的异常处理
我正在使用以下代码使用 PowerShell 1.0 上传文件。如何判断上传是否成功完成或是否有错误?如果上传成功,我需要删除文件。
我尝试过
的:1.陷阱条款。似乎无法让这个工作。
2.检查$webclient.UploadFile的返回值——这似乎总是一个空字符串,成功与否
powershell - 帮我使用 powershell 和 bcp 将 CSV 加载到 SQL Server
我正在使用 bcp 从远处的其他人从另一个表导出的 CSV 加载一个表,并且遇到了一些问题。我原来的两个问题:一个导出的字段是一个需要以 varchar 字段结尾的 int,另一个字段需要用静态字符串填充。好吧,第一个没什么大不了的,Chad 的回答让我想到了@{n='Col3';e={'ABC'}}
语法。但是我在正确加载数据时遇到了几个问题。
有时一个值可能没有空格,有时它可能。如何在 bcp 格式文件中指定分隔符?我问是因为大概我需要用引号括起来。
一种。我应该用引号将中间 CSV 文件中的值包装起来吗?
在我的测试代码中,它将列标题和换行推入 Col1,第一行的实际值为 Col1。
在我实际的、未经处理的代码中,我进入
String data, right truncation
了第一行,尽管第二行插入正常。
无论如何,我从其他地方获得的初始 CSV 数据看起来像这样(注意:没有标题行)
目标SQL表是这样的
我需要将ABC123加载到123456中Col1
,将Export1加载到APPLE中。Export1是静态字符串。我在 Powershell 1.0 中这样做。Col2
Col3
Col4
编辑:乍得的 import-csv | export-csv 看起来很有希望,但它不喜欢缺少标题,并且 PS 1.0 不支持 -Header 选项。
编辑:上面的编辑描述以反映我是如何走到这一点的。四列表格和三列 CSV 显然是简化的。一个真正的列是一个城市,因此它可以包含简单的字符串或需要引用的字符串。此时我的 Powershell 1.0 代码如下。
powershell - 帮助从字符串中提取特定数据的脚本
以下是单个文件中的数据列表。我想在 Powershell 中运行它。
LESCAR85 07/31/10 1700678991 / 70039536 $35.00
SQUADCT8 07/31/10 1698125739 / 70039539 $35.00
RINGFIEL 07/29/10 11041563 / 70039639 $35.00
最后的 8 位数字和美元金额我想转换为 csv,以便我可以在 excel 文件中使用它。第一组较长的数字并不总是相同的,这会改变我需要的 8 位数字序列和美元金额之间的空格数。
谢谢!
powershell - 从 powershell 脚本执行 powershell.exe(在 ISE 中运行,但不在脚本中)
我是这些很棒的 Power shell 世界的新手。我的脚本有问题,非常感谢您的帮助。
我有一个脚本“cmd4.ps1”需要运行另一个脚本“Transfer.ps1”,该脚本需要接收 3 个字符串参数,并且它需要作为不同于“cmd4.ps1”的其他进程运行。
cmd4.ps1:
弹出后,$Script
硬币的值类似于
包含使用-File
参数运行Powershell.exe脚本的语法,以及Transfer.ps1需要的三个参数("http://10.1.1.1/Upload/file.txt", 10.1.1.1, 10.1.1.10
)。
当我在 PowerShell ISE 中编写这些指令时,我可以看到每个值都是正确的,并且 PowerShell.exe 以正确的值执行,一切正常!但是如果我将这些指令放在“cmd4.ps1”脚本中,它就不起作用了,我意味着参数不正确,因为我可以看到它启动 powershell 但它永远不会结束。
powershell - PowerShell v1 中的等效加载模块
出于脚本可移植性的原因,我需要在 PowerShell 脚本中动态加载管理单元。这很容易在 PowerShell v2 中使用该Load-Module
功能完成。我需要在一台机器上运行这个特定的脚本,由于各种原因,我不想安装 PowerShell v2,但有 v1。
PowerShell v1 中是否有Load-Module
等价物?
.net-3.5 - PowerShell 1.0 能否托管用 .NET 3.5 编写的 Cmdlet?
当我尝试在 PowerShell 1.0 中加载我的管理单元时,它会失败并显示一个错误,指出由于对 .NET 3.5 的依赖而无法加载我的程序集,这与当前加载的 .NET 版本不同。
是否可以解决此问题并让 PowerShell 1.0 加载依赖于 .NET 3.5 的 Cmdlet,或者是升级到 PowerShell 2.0 的唯一选择?
powershell - Find Three files of the Same Name but create with Different Applications
I am looking for a way to find three or more files of the same name but created with another application. Next action is then compare all three files to see if they were create on the same date and finaly compare that date against the current OS date.