如何从Excel中提取数据,以便在第一列中包含机器的详细信息,在第二列中包含多个用户名,并且它读取Excel,就像它将通过在第1列中写入的机器名称删除第2列中的所有用户。我的脚本尝试过-
全部清除
工作表名称 = @()
$excel=new-object -com excel.application
$wb=$excel.workbooks.open("c:\users\administrator\my_test.xls")
for ($i=1; $i -le $wb.sheets.count; $i++)
{
$sheetname+=$wb.Sheets.Item($i).Name;
}
Run Code Online (Sandbox Code Playgroud)
但无法以我想要运行的格式读取。
我希望我的脚本在没有任何第三方工具的情况下使用命令提示符/powershell 获取屏幕截图我该怎么做,它应该看起来像这样"C:\Windows\System32\screenshot.exe" "C:\Users\%username%\Pictures\screenshot.png"
我尝试使用选项在 Windows 上挂载 NFS 共享,但出现错误。
PS C:\Users\cclloyd> mount 10.0.40.1:/srv/Config H: -o nolock
New-PSDrive: Parameter cannot be processed because the parameter name 'o' is ambiguous. Possible matches include: -OutVariable -OutBuffer.
Run Code Online (Sandbox Code Playgroud)
为什么我会收到此错误?所有指南和教程都表明该命令运行良好。我也在 Windows 中安装了所有 NFS 服务。
在 Powershell 5.1 中,只要按一下F7,就会显示之前输入的命令的历史记录。我刚刚安装了 Powershell 7.2,但F7不再执行任何操作。F8尽管如此,仍然会根据命令历史记录自动完成。
我在 Windows 终端中使用带有 Powershell 的 Windows 11。当我尝试获取 debian ISO 的 sha512 时,我得到以下令人沮丧的输出:
PS C:\Users\xdavi\Documents> get-filehash -algorithm sha512 .\debian-11.4.0-amd64-netinst.iso
Algorithm Hash Path
--------- ---- ----
SHA512 EEAB770236777E588F6CE0F984A7F3E85D86295625010E78A0FCA3E873F78188AF7... C:\Users\xdavi\Documents\debian-11.4.0-amd64-netinst.iso
Run Code Online (Sandbox Code Playgroud)
注意8AF7...末尾有省略号;这是被截断的。我如何看待整个事情?
目前,nvim 使用的默认 shell 是cmd.exe我尝试通过在 nvim 配置中将 shell 设置为 powershell 来更改它,但这不起作用,所以我在 nvim 命令行中尝试了以下命令:
:let &shell = 'path/to/powershell.exe'
Run Code Online (Sandbox Code Playgroud)
Echo shell 命令输出 powershell 路径,当我执行时:terminal它打开了一个powershell选项卡,但退出并重新打开 nvim 后它仍在使用cmd.exe
如何将默认 shell 永久更改为 powershell?
当我使用 Get-ChildItem cmdlet 时,我发现了一种奇怪的行为
文件夹结构:
d:\test\fooA\foo\1-9.txt files
d:\test\fooB\foo\1-9.txt files
d:\test\fooC\foo\1-9.txt files
d:\test\fooD\foo\1-9.txt directories
Run Code Online (Sandbox Code Playgroud)
当我使用以下语法时,我将从所有递归文件夹中获取所有 1-9.txt 文件和目录。它按预期工作。
Get-ChildItem -Filter *.txt -Path D:\test\*\foo -Recurse
Run Code Online (Sandbox Code Playgroud)
当我添加参数 -Directories 时,我仅从示例中的最后一个文件夹中获取目录。它也按预期工作。
Get-ChildItem -Directory -Filter *.txt -Path D:\test\*\foo -Recurse
Run Code Online (Sandbox Code Playgroud)
当我添加参数 -File 而不是 -Directories 时,我什么也得不到。我预计我只会得到文件。
Get-ChildItem -File -Filter *.txt -Path D:\test\*\foo -Recurse
Run Code Online (Sandbox Code Playgroud)
当我使用参数 -File 和 -Directory 时,我也什么也得不到。
Get-ChildItem -Directory -File -Filter *.txt -Path D:\test\*\foo -Recurse
Run Code Online (Sandbox Code Playgroud)
我在不同的 Windows 系统上测试了 PowerShell 版本 5.1 和 7。从我的角度来看,它看起来更像是错误,而不是代码中的问题,或者我对这个 cmdlet 用法的理解,有人可以仔细检查和评论吗?我可以通过额外的编码来解决我的问题,但我不明白为什么它适用于文件夹而不适用于文件。
非常感谢您的任何评论。
如何从 Windows 7 中删除 PowerShell 1.0 以安装 PowerShell 2.0。?我在已安装的程序和更新列表中找不到它。
我正在寻找做这个问题中提出的问题:how to run a powershell script as administrator
接受的答案说使用快捷方式。我想这样做,但是当我进入高级属性时,一切都变灰了。我该如何解决这个问题?
我有一个以这种方式工作的 Powershell manteinance 脚本:
kill explorer
do things
restart explorer
Run Code Online (Sandbox Code Playgroud)
此脚本以提升模式执行,但我需要在没有管理员权限的情况下重新启动资源管理器。任何的想法?
谢谢
powershell ×10
windows ×3
asterisk ×1
cmd.exe ×1
command-line ×1
nfs ×1
path ×1
screenshot ×1
script ×1
shell ×1
shell-script ×1
vim ×1
windows-11 ×1
windows-7 ×1