我有一个简单的问题。什么是 Git Shell?它与 Windows Power Shell 相同吗?
因为当我在 Windows 7 机器上运行 Git Shell 时,会打开 Windows Power Shell。
感谢您的澄清。
例如,如果我键入这样的命令:
Get-Childitem | where-object {$_lastwritetime.Day -eq "$data"} |sort-object lastwrittetime
Run Code Online (Sandbox Code Playgroud)
我想为它取一个别名,我试图做这样的事情:
set-alias Check -value (and there is above command)
Run Code Online (Sandbox Code Playgroud)
然后别名工作,但忽略后的命令Get-Childitem。
Windows 8 中有两种不同的 Internet Explorer 版本。我想从命令行打开桌面 Internet Explorer。
我们可以通过Win+运行它R?iexplore,但我想从命令提示符或 PowerShell 运行它。可以做到吗?
假设我有这个功能:
function Foo{
[CmdLetBinding()]
param(
[Parameter(Mandatory=$true,ParameterSetName="A",Position=0)]
[Parameter(Mandatory=$true,ParameterSetName="both",Position=0)]
[int]
$A,
[Parameter(Mandatory=$true,ParameterSetName="B",Position=0)]
[Parameter(Mandatory=$true,ParameterSetName="both",Position=1)]
[int]
$B
)
Write-Host $PsCmdlet.ParameterSetName
}
Run Code Online (Sandbox Code Playgroud)
我希望这种方法可以期待 A 或 B 或两者兼而有之。从来没有。
但是,如果我称之为:
Foo -A 1 -B 2 # outputs "both" as expected
Foo -B 3 # error
Foo -A 4 # error
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
Foo : Parameter set cannot be resolved using the specified named parameters.
At c:\pathto:75 char:4
+ Foo <<<< -B 3
+ CategoryInfo : InvalidArgument: (:) [Foo], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,Foo
Foo : Parameter set cannot …Run Code Online (Sandbox Code Playgroud) 鉴于 Office 2013 即点即用安装程序不允许对安装进行任何自定义,我该如何安装,或者在哪里可以找到主互操作程序集/.NET 程序集的安装程序?
其他信息:
这个问题是固有的,因为我使用的是利用 Word Interop 程序集的 PowerShell 脚本。它在 Office 2010 安装下工作,但在 Office 2013 中出现错误。从研究来看,我似乎需要安装 Office 2013 PIA,但找不到如何安装。
在 PowerShell 中,有没有办法在键入一个长或复杂的命令后将该命令提交到历史缓冲区,但不执行它?
例如,您开始在 posh-git:directory 中输入 git commit:
git commit -m "Added the library 'ASDF' and did some initial integration into the project" [pause]
Run Code Online (Sandbox Code Playgroud)
就在你输入的时候,我在想......呃,我需要先做一些事情,比如添加一个额外的文件来提交先做其他事情,或者创建一个目录或其他东西(人为的情况,我意识到 PowerShell 会自动创建它,我意识到 git 可以“修改提交”。)所以我想将该提交消息保存到历史缓冲区中,但不运行它,以便稍后在我说、暂存其他文件或执行某些操作后调用就在之前。
根据这篇文章Windows PowerShell Shortcut Keys,似乎没有击键可以执行此操作。
Esc键(和Ctrl+ C)将取消命令,并将其清除......我需要的是保存到历史记录,稍后运行,从而保留我的输入。有这个按键吗?
我在我的 Windows 2008 R2 服务器上有一个计划任务,它应该运行一个 powershell 脚本来从另一台服务器下载文件的备份。在同一台服务器上,我已经安排了完全相同的任务从其他 2 个服务器运行和下载 - 这些任务工作正常。
特别是这一任务似乎从来没有做任何事情。任务历史记录表明它已成功执行,但从未下载文件。如果我手动运行 powershell 脚本,则会下载文件。如果我手动运行自动任务,文件将再次下载。如果我断开连接第二天来检查,文件还没有下载。
无论用户是否登录,我都将它设置为运行。为什么它不起作用?如何启用更详细的日志记录?
windows powershell windows-server-2008 windows-task-scheduler
我通常在 Windows 上使用 windows powershell 而不是命令提示符。我注意到,当我在 Windows 启动后第一次启动它时,需要很长时间才能显示命令提示。
为了解决这个问题,我启动它,然后立即关闭它,然后再次启动它。如果我这样做,它几乎立即开始。
有没有办法确保命令提示立即出现,而不是我必须做这个小技巧?
我需要能够使用 PowerShell 脚本管理我的环境。我需要定期更改我的主机文件。但是,每当我尝试从脚本编辑主机时,都会出现以下错误:
Access to the path C:\windows\system32\drivers\etc\hosts is denied
Run Code Online (Sandbox Code Playgroud)
目前我的脚本如下所示:
Function ManageHosts([string] $environment)
{
cd C:\windows\system32\drivers\etc
if($environment.StartsWith("p"))
{
get-content .\hosts.prod | set-content .\hosts -force
}
else
{
get-content .\hosts.dev | set-content .\hosts -force
}
}
Run Code Online (Sandbox Code Playgroud) 有没有办法通过在上面拖放文件来运行 powershell 脚本(就像将文件拖放到 .exe 文件一样)?能够对文件夹做同样的事情也很好......
powershell ×10
windows-7 ×4
command-line ×2
windows ×2
git ×1
history ×1
shell ×1
shell-script ×1
windows-8 ×1