我最近将别名设置为非命令,因为我不知道如何使用设置别名。我想知道如何重置所有别名而不影响 powershell 附带的默认别名。
我尝试使用Remove-Alias但它返回给我这个错误:
PS C:\Users\me\Desktop\Projet\> Remove-Alias lua
Remove-Alias : The term 'Remove-Alias' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a
path was included, verify that the path is correct and try again.
At line:1 char:1
+ Remove-Alias lua
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Remove-Alias:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Run Code Online (Sandbox Code Playgroud) 我想尝试使用 PowerShell 作为 Ubuntu 18.04 上的默认 shell,但是使用 bash,我可以选择运行一些命令,但sudo我不确定如何使用 PowerShell 来执行此操作,因为它没有sudo作为一个概念。
在 Windows 上的 PowerShell 中,您必须以管理员身份运行 shell。如果我将默认 shell 设置为 PowerShell,我担心如果没有 sudo,我将无法运行我可能需要的命令,我是否必须进入 bash?我不想默认以管理员身份运行默认 shell。
我在 Windows 中创建了一个计划任务,以在特定时间运行 powershell 脚本。正如您所看到的,在操作页面中,我已指定 powershell 路径作为程序,并将我的脚本指定为参数。计划任务运行良好。
我想包括我自己的日志文件,该文件在那里打印我的脚本的输出。我怎样才能做到这一点?
我试图将任何错误重定向到 null,但我似乎无法理解它。有什么帮助吗?
这是我的代码:$names | foreach-object{Copy-Item -Path C:\Users\$_\* -Destination C:\Users\$user\Desktop\${_}_removed -Recurse} | out-null
我有以下命令:
& '.\FocusAssist\LGPO\LGPO.exe' /t '.\FocusAssist\disable_toast_notifications.txt'
如果我使用管理员权限打开 Windows Powershell,该命令将成功运行。
但是,如果我将此命令放入 .bat 文件(我们称之为disable_toast_notifications.bat)中,该命令将无法运行。我努力了:
'.\FocusAssist\LGPO\LGPO.exe' /t '.\FocusAssist\disable_toast_notifications.txt'或& '.\FocusAssist\LGPO\LGPO.exe' /t '.\FocusAssist\disable_toast_notifications.txt'作为 的内容disable_toast_notifications.bat(区别在于&命令开头的 )。如何成功运行这个 .bat 文件?.bat 文件是否需要不同的语法?
我有一个很大的日志文件(.log)。我试图找到一些需要突出显示的关键字,以便我可以更快地跳过日志中的其他行。但是,我不想只过滤选择字符串,而是突出显示选择字符串。另外,我对Powershell一无所知,到目前为止,我通过谷歌搜索得到了以下命令。
C:\users\proto> cat txtlog.log select-string "Valid" | write-host -foregroundcolor red
Run Code Online (Sandbox Code Playgroud)
它不会输出我想要的内容,因为它只返回红色的“有效”行,而不返回其他行。
我确实需要检查在 Windows PowerShell 中运行的命令的数值。
\n唯一$?返回 True 或 False,但我需要实际的错误号。
那可能吗?在linux下就可以了,echo $?但是在Windows下就很难了!
PS C:\\work\\> copy\n\nCmdlet Copy-Item an der Befehlspipelineposition 1\nGeben Sie Werte f\xc3\xbcr die folgenden Parameter an:\nPath[0]:\nPS C:\\work\\> echo $?\nFalse\nPS C:\\work\\>\nRun Code Online (Sandbox Code Playgroud)\n当您在这里时,正常命令提示符的解决方案是什么?
\n这样我就可以确定设备的传输速率并将其与 PCIE 设备的生成(PCIE 3.0、4.0 等)相关联
最近 Windows Terminal 进行了更新,并获得了历史记录建议。它看起来像这样:
当我输入时,它会显示与我的输入相匹配的历史记录项。我以为按 Tab 会自动完成灰色部分,但事实并非如此。我尝试了各种其他热键,但它们也没有任何作用。我查看了 Windows 终端设置,但找不到任何相关内容。
我该怎么做才能完成文本?
PS 我不能 100% 确定这是否是 Windows 终端功能。我想它可能是 Powershell 或 PSReadLine。
我正在尝试msi使用安装 Window 应用程序驱动程序包cmd /PS
,但无法管理它,因为该包似乎需要用户交互
msiexec /i D:\a\test\ultimate\WindowsApplicationDriver_1.2.1.msi /qn
Run Code Online (Sandbox Code Playgroud)
运行上面的命令并没有安装应用程序,而且我没有看到任何输出。我需要将此应用程序安装在默认位置,并在后台执行。
powershell ×10
windows ×5
command-line ×3
windows-10 ×3
bash ×1
batch-file ×1
motherboard ×1
pci-express ×1
shell ×1
terminal ×1
ubuntu ×1
windows-11 ×1