Get-pc falls back to cmdb when pc is offline and not in SCCM
This commit is contained in:
parent
8cc3bbbeb4
commit
00d4adfe7b
|
|
@ -392,7 +392,6 @@ function Get-PCBatchInvoke {
|
||||||
}
|
}
|
||||||
BatchInvokesProgressBar -stage 3
|
BatchInvokesProgressBar -stage 3
|
||||||
$output += $invokeJob | Receive-Job -Wait -AutoRemoveJob | Select-Object * -ExcludeProperty RunspaceId, PSComputerName, PSShowComputerName, PSSourceJobInstanceId
|
$output += $invokeJob | Receive-Job -Wait -AutoRemoveJob | Select-Object * -ExcludeProperty RunspaceId, PSComputerName, PSShowComputerName, PSSourceJobInstanceId
|
||||||
$output += $offlineJobs | Receive-Job -Wait -AutoRemoveJob | Select-Object * -ExcludeProperty RunspaceId, PSComputerName, PSShowComputerName, PSSourceJobInstanceId
|
|
||||||
$itemIndex = 0
|
$itemIndex = 0
|
||||||
$contactedhosts = $output.Hostname
|
$contactedhosts = $output.Hostname
|
||||||
BatchInvokesProgressBar -stage 4
|
BatchInvokesProgressBar -stage 4
|
||||||
|
|
@ -403,7 +402,16 @@ function Get-PCBatchInvoke {
|
||||||
$missedJobs += Start-Job -ScriptBlock ${function:Get-SCCMQueryBlock} -ArgumentList $computer
|
$missedJobs += Start-Job -ScriptBlock ${function:Get-SCCMQueryBlock} -ArgumentList $computer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$output += $offlineJobs | Receive-Job -Wait -AutoRemoveJob | Select-Object * -ExcludeProperty RunspaceId, PSComputerName, PSShowComputerName, PSSourceJobInstanceId
|
||||||
$output += $missedJobs | Receive-Job -Wait -AutoRemoveJob | Select-Object * -ExcludeProperty RunspaceId, PSComputerName, PSShowComputerName, PSSourceJobInstanceId
|
$output += $missedJobs | Receive-Job -Wait -AutoRemoveJob | Select-Object * -ExcludeProperty RunspaceId, PSComputerName, PSShowComputerName, PSSourceJobInstanceId
|
||||||
|
BatchInvokesProgressBar -stage 5
|
||||||
|
#CMDB cycle of missed hosts
|
||||||
|
$missedhosts = $Computers | Where-Object -FilterScript {$_ -notin $output.Hostname}
|
||||||
|
if($missedhosts.count -gt 0){
|
||||||
|
foreach($computer in $missedhosts){
|
||||||
|
$output += Get-CMDBFallback $computer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $output
|
return $output
|
||||||
|
|
||||||
|
|
@ -445,8 +453,9 @@ function BatchInvokesProgressBar {
|
||||||
switch ($stage) {
|
switch ($stage) {
|
||||||
1 { Write-Progress -Activity "Connecting to computers" -Status "$item ($currentItemIndex/$TotalItems)" -PercentComplete (($currentItemIndex/$TotalItems) * 100)}
|
1 { Write-Progress -Activity "Connecting to computers" -Status "$item ($currentItemIndex/$TotalItems)" -PercentComplete (($currentItemIndex/$TotalItems) * 100)}
|
||||||
2 { Write-Progress -Activity "Spinning up jobs" -PercentComplete ((20/100) * 100)}
|
2 { Write-Progress -Activity "Spinning up jobs" -PercentComplete ((20/100) * 100)}
|
||||||
3 { Write-Progress -Activity "Awaiting Jobs" -PercentComplete ((60/100)*100)}
|
3 { Write-Progress -Activity "Awaiting Online Jobs" -PercentComplete ((60/100)*100)}
|
||||||
4 { Write-Progress -Activity "Querying SCCM for missed computers" -PercentComplete ((75/100) * 100)}
|
4 { Write-Progress -Activity "Querying SCCM for offline computers" -PercentComplete ((75/100) * 100)}
|
||||||
|
5 { Write-Progress -Activity "Querying CMDB for computers not in SCCM" -PercentComplete ((75/100) * 100)}
|
||||||
Default {}
|
Default {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#region Module Import Block
|
#region Module Import Block
|
||||||
|
|
||||||
#$ErrorActionPreference = 'SilentlyContinue'
|
$ErrorActionPreference = 'SilentlyContinue'
|
||||||
#DevStage can take either Dev or Prod as values
|
#DevStage can take either Dev or Prod as values
|
||||||
$devStage = 'Dev'
|
$devStage = 'Dev'
|
||||||
#Locations for dev build and prod build
|
#Locations for dev build and prod build
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue