我有一个Get-WmiObject使用-Credential. 但是,如果我在本地机器上运行它,则会出错:
Get-WmiObject : User credentials cannot be used for local connections
添加 if localhost 逻辑以避免此错误的正确方法是什么?或者,还有更好的方法?
对于 Windows 2008,我需要创建一个脚本来显示连接的 RDP 会话是否设置为“高”加密或其他(例如,“兼容”)。
有没有人知道一种无需通过 GUI 即可获得此功能的方法?
我调查了 wmic 和 powershell,但找不到任何东西。我找到了一个用于终端服务的 .net Powershell 模块,但它所做的只是显示状态(即列出会话)。我实际上需要查看加密级别。
powershell windows-server-2008 rdp command-line-interface remote-desktop-services
我无法通过远程 PowerShell 会话运行 Exchange 2010 cmdlet。
我以管理员身份启动本地 PowerShell 会话并发出以下命令——
PS C:\Windows\system32> $mailcred = Get-Credential
PS C:\Windows\system32> $mailSession = New-PSSession -ComputerName MAILSRV -Credential $mailcred
PS C:\Windows\system32> Enter-PSSession $mailSession
[MAILSRV]: PS C:\Users\jdoe\Documents> Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
[MAILSRV]: PS C:\Users\jdoe\Documents> hostname
MAILSRV
[MAILSRV]: PS C:\Users\jdoe\Documents> Get-ExchangeServer
Value cannot be null.
Parameter name: serverSettings
+ CategoryInfo :
+ FullyQualifiedErrorId : System.ArgumentNullException,Microsoft.Exchange.Management.SystemConfigurationTasks.GetExchangeServer
[MAILSRV]: PS C:\Users\jdoe\Documents> get-mailbox
Value cannot be null.
Parameter name: serverSettings
+ CategoryInfo :
+ FullyQualifiedErrorId : System.ArgumentNullException,Microsoft.Exchange.Management.RecipientTasks.GetMailbox
Run Code Online (Sandbox Code Playgroud)
如您所见,所有 Exchange cmdlet 都不起作用。可能是什么问题?
Exchange 管理工具输出它们将(或刚刚)执行的确切 PS 命令。是否存在具有类似功能的不同版本的 AD 工具(主要是 AD 用户和计算机)?如果不是,这是 Windows 8 Server 的预期功能吗?
powershell windows-server-2008 active-directory windows-server-2008-r2 windows-server-2012
在服务器核心中,重新启动后突然没有安装powershell,我该怎么做才能重新安装它?
我还没有设置远程管理,所以我不能用它来重新安装它。
'powershell' 不是内部或外部命令、可运行的程序或批处理文件。
我在 Windows 7 机器上安装了 Windows Management Framework 3.0 并尝试使用 New-SMBShare cmdlet,但是当我运行 get-command new-smb* 时,没有找到任何 cmdlet。如何在 Windows 7 中使用这个新的 cmdlet 以及任何其他新的 cmdlet?
所以这是这个目录中可用模块的列表。正如你所看到DnsShell的那样。
PS C:\windows\system32> Get-Module -ListAvailable
Run Code Online (Sandbox Code Playgroud)
目录:C:\windows\system32\WindowsPowerShell\v1.0\Modules
ModuleType Name ExportedCommands
---------- ---- ----------------
Manifest ActiveDirectory {Get-ADRootDSE, New-ADObject, Rename- ADObject, Move-ADObject...}
Manifest AppLocker {Set-AppLockerPolicy, Get-AppLockerPolicy, Test-AppLockerPolicy, Get-AppLo...
Manifest BitsTransfer {Add-BitsFile, Remove-BitsTransfer, Complete-BitsTransfer, Get-BitsTransfe...
Manifest CimCmdlets {Get-CimAssociatedInstance, Get-CimClass, Get-CimInstance, Get-CimSession...}
Binary DnsShell
Script ISE {New-IseSnippet, Import-IseSnippet, Get- IseSnippet}
Manifest Microsoft.PowerShell.Diagnostics {Get-WinEvent, Get-Counter, Import-Counter, Export-Counter...}
Manifest Microsoft.PowerShell.Host {Start-Transcript, Stop-Transcript}
Manifest Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear- ItemProperty, Join-Path...}
Manifest Microsoft.PowerShell.Security {Get-Acl, Set-Acl, Get-PfxCertificate, Get-Credential...}
Manifest Microsoft.PowerShell.Utility {Format-List, Format-Custom, Format-Table, Format-Wide...}
Manifest Microsoft.WSMan.Management {Disable-WSManCredSSP, Enable- …Run Code Online (Sandbox Code Playgroud) 我正在尝试从脚本中Task Scheduler的本地计算机打印信息,PowerShell以便其他用户也可以打印此信息而不必访问Task Scheduler. 我需要脚本打印出来
我可以打印出有关名称、下次运行时间和上次运行时间的信息,但在运行脚本时不会打印出其余的信息。
我已经对我的脚本有了一个小小的开始,并把字段放下了。
$schedule = new-object -com("Schedule.Service")
$schedule.connect()
$tasks = $schedule.getfolder("\").gettasks(0)
$tasks | select Name,Status,Triggers,NextRunTime,LastRunTime,LastRunResult,Author,Created | ft
foreach ($t in $tasks)
{
foreach ($a in $t.Actions)
{
$a.Path
}
}
Run Code Online (Sandbox Code Playgroud)
任何帮助或建议将不胜感激。
以下是我正在寻找的内容以及哪些字段未打印出数据的屏幕截图:

powershell windows-server-2008 task-scheduler windows-server-2012
我遇到了一个完整的障碍,无法弄清楚如何在IIS 8. 我一直在检索应用程序和空的空参数错误,只是找不到让虚拟目录列出的方法。
我需要以下数据来列出有关虚拟目录的信息:
下面是我一直在使用和弄乱的代码:
*See revised code below*
Run Code Online (Sandbox Code Playgroud)
我还使用该Appcmd.exe命令尝试列出虚拟目录:
C:\Windows\System32\inetsrv\appcmd.exe LIST VDIRS
Run Code Online (Sandbox Code Playgroud)
但我仍然没有得到我需要的输出。任何或任何帮助将不胜感激!谢谢!
通过注释几行来列出我的虚拟目录,但它只打印出名称和:
我仍然不知道,以下是修改后的代码:
Import-Module WebAdministration
$Websites = Get-ChildItem IIS:\Sites
foreach($Site in $Websites)
{
$webapps = Get-WebApplication -Site $Site.name
$VDir = Get-WebVirtualDirectory -Site $Site.name #-Application $webapps.name
foreach($webvdirectory in $VDir)
{ …Run Code Online (Sandbox Code Playgroud) 已经为此苦苦挣扎了几天了。
我收到以下错误:
PS C:\> get-process -ComputerName Win2012r2
get-process : Couldn't connect to remote machine.
At line:1 char:1
+ get-process -ComputerName 10.10.1.54
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-Process], InvalidOperationException
+ FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.GetProcessCommand
Run Code Online (Sandbox Code Playgroud)
我已经确认远程注册表服务正在服务器上运行(我也尝试重新启动它)。
此外,我创建了一个自定义防火墙规则,允许每个/sf/ask/1564994441/在端口 5985 && 5986 上建立 RCP 连接。 命令做
我还仔细检查了每个Powershell Get-Process 无法连接到远程计算机的用户名
笔记
invoke-command -ComputerName Win2012r2 -ScriptBlock {Get-Process}工作正常,但我真的需要让这个get-process -computername过程直接工作,因为它在其他人使用的另一个脚本中失败了