【发布时间】:2013-01-23 15:46:46
【问题描述】:
为什么 Quest.ActiveRoles.ADManagement 在作业中不可用?
交互运行时可以:
PS>Get-QADComputer -SearchRoot '$ou' -SizeLimit 200 |
%{ if (Test-Connection -Quiet $_.name) {
$lastboottime = (Get-WmiObject -Class Win32_OperatingSystem -computername $_.name).LastBootUpTime;
$sysuptime = (Get-Date) - System.Management.ManagementDateTimeconverter]::ToDateTime($lastboottime)
write-host "$($_.name) allumé depuis $($sysuptime.days) jours" } }
domain\comp1$ allumé depuis 8 jours
domain\comp2$ allumé depuis 0 jours
但是在使用作业时:
PS>start-job -Name uptime -ScriptBlock{Get-QADComputer -SearchRoot '$ou' -SizeLimit 200 |
%{ if (Test-Connection -Quiet $_.name) {
$lastboottime = (Get-WmiObject -Class Win32_OperatingSystem -computername $_.name).LastBootUpTime;
$sysuptime = (Get-Date) - System.Management.ManagementDateTimeconverter]::ToDateTime($lastboottime)
write-host "$($_.name) allumé depuis $($sysuptime.days) jours" } }}
它抱怨找不到命令
PS>Receive-Job uptime -Keep
Le terme «Get-QADComputer» n'est pas reconnu comme nom d'applet de commande,
fonction, fichier de script ou programme exécutable. Vérifiez l'orthographe du
nom, ou si un chemin d'accès existe, vérifiez que le chemin d'accès est correct et
réessayez.
+ CategoryInfo : ObjectNotFound: (Get-QADComputer:String) [], Command
NotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
+ PSComputerName : localhost
【问题讨论】:
标签: powershell jobs powershell-3.0 quest