我正在使用 PowerShell 脚本,它们运行良好。但是,我想知道是否有任何方法可以显示所有已运行的命令,就像您自己手动输入它们一样。这类似于批处理文件中的“回显”。我查看了 PowerShell 命令行参数和 cmdlet,但没有发现任何明显的东西。谢谢!
我到处都在阅读PowerShell是未来的方式。当它第一次发布时,我做了一大堆虚拟实验室,但从那以后我还没有在生产环境中使用它。我知道有一天我会处理已经安装了操作系统的操作系统,所以我想做好准备。
我想知道:
似乎每个人都同意微软正在努力推动这一点,但实际上还没有人使用它。我想听听使用它来完成日常任务并分享一些代码示例的系统管理员的意见。
windows powershell windows-server-2003 windows-server-2008 sql-server
我的 Windows Vista 计算机上只有一个帐户,并且该用户具有管理权限。但是,当我尝试在 PowerShell 中执行命令以终止某个进程时,我收到一条“访问被拒绝”消息。我如何成为管理员?
我正在尝试使用 递归删除一个目录rm -Force -Recurse somedirectory,我收到了几个“目录不是空的”错误。如果我重试相同的命令,它会成功。
例子:
PS I:\Documents and Settings\m\My Documents\prg\net> rm -Force -Recurse .\FileHelpers
Remove-Item : Cannot remove item I:\Documents and Settings\m\My Documents\prg\net\FileHelpers\FileHelpers.Tests\Data\RunTime\_svn: The directory is not empty.
At line:1 char:3
+ rm <<<< -Force -Recurse .\FileHelpers
+ CategoryInfo : WriteError: (_svn:DirectoryInfo) [Remove-Item], IOException
+ FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand
Remove-Item : Cannot remove item I:\Documents and Settings\m\My Documents\prg\net\FileHelpers\FileHelpers.Tests\Data\RunTime: The directory is not empty.
At line:1 char:3
+ rm <<<< -Force -Recurse .\FileHelpers
+ CategoryInfo : WriteError: …Run Code Online (Sandbox Code Playgroud) 有没有办法从 Server 2012 中的命令行运行具有提升权限的 Powershell 提示?
问题是这是“最小服务器接口”模式,没有安装完整的 server-gui,所以我只能从命令提示符或 ServerManager 运行 powershell。
我实际上是在尝试运行以下命令:Enable-ServerManagerStandardUserRemoting,但尽管这似乎有效,但它并没有像预期的那样将有问题的用户添加到各个组中。我怀疑它不能正常工作,因为我没有从完全提升的 powershell 提示符运行它,只是一个标准的提示符,但作为管理员。
谢谢,尼克
我正在使用一个 Powershell 脚本,该脚本将计划任务添加到我们域中的系统中。当我运行这个脚本时,它会提示我输入密码。有时我会粗指密码并启动该过程,从而锁定我的帐户。有没有办法验证我的凭据以确保我输入的内容将通过域进行验证?
我想找到一种查询域控制器的方法。我已经进行了一些 Google 搜索,我应该能够执行 WMI 查询并捕获错误。如果可能,我想避免这种验证方式。
有任何想法吗?提前致谢。
我正在尝试在 powershell 中使用 robocopy 来镜像我家用机器上的一些目录。这是我的脚本:
param ($configFile)
$config = Import-Csv $configFile
$what = "/COPYALL /B /SEC/ /MIR"
$options = "/R:0 /W:0 /NFL /NDL"
$logDir = "C:\Backup\"
foreach ($line in $config)
{
$source = $($line.SourceFolder)
$dest = $($line.DestFolder)
$logfile = $logDIr
$logfile += Split-Path $dest -Leaf
$logfile += ".log"
robocopy "$source $dest $what $options /LOG:MyLogfile.txt"
}
Run Code Online (Sandbox Code Playgroud)
该脚本接收一个包含源目录和目标目录列表的 csv 文件。当我运行脚本时,我收到以下错误:
-------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows
-------------------------------------------------------------------------------
Started : Sat Apr 03 21:26:57 2010
Source : P:\ C:\Backup\Photos \COPYALL \B …Run Code Online (Sandbox Code Playgroud) 如果我有一个脚本需要在多台计算机上运行,或者有多个不同的参数,我如何并行执行它,而不必产生产生新PSJobStart-Job的开销?
例如,我想重新同步所有域成员的时间,如下所示:
$computers = Get-ADComputer -filter * |Select-Object -ExpandProperty dnsHostName
$creds = Get-Credential domain\user
foreach($computer in $computers)
{
$session = New-PSSession -ComputerName $computer -Credential $creds
Invoke-Command -Session $session -ScriptBlock { w32tm /resync /nowait /rediscover }
}
Run Code Online (Sandbox Code Playgroud)
但我不想等待每个 PSSession 连接并调用命令。如果没有乔布斯,这如何并行完成?
我管理 Windows Server 2012 服务器。我正在学习 PowerShell 通过命令行管理这些服务器。我的工作站运行 Ubuntu,我通常通过 SSH 连接来管理 Linux 服务器。
有没有一种方法可以让我从 Linux 工作站通过命令行(如 Linux 上的 SSH 访问)在 Windows 服务器上使用 Windows PowerShell?
我使用当前的 Windows 10 和 Powershell 5.1。通常,我想查找我过去使用过的命令来修改和/或重新运行它们。不可避免地,我正在寻找的命令是在以前的或不同的 PowerShell 窗口/会话中运行的。
当我敲击?钥匙时,我可以浏览许多来自许多会话的许多命令,但是当我尝试使用 搜索它们时Get-History | Where-Object {$_.CommandLine -Like "*docker cp*"},我没有得到任何结果。基本的故障排除显示Get-History没有显示以前会话中的任何内容,如下所示:
C:\Users\Me> Get-History
Id CommandLine
-- -----------
1 Get-History | Where-Object {$_.CommandLine -Like "*docker cp*"}
Run Code Online (Sandbox Code Playgroud)
如何?使用密钥Get-History或其他 Cmdlet搜索先前提供的命令?
powershell ×10
windows ×3
automation ×1
command ×1
domain ×1
password ×1
performance ×1
permissions ×1
robocopy ×1
sql-server ×1