Intune Initial Scripts Backup
This commit is contained in:
73
dump/NA-Collections-Updates-Downloaded.ps1
Normal file
73
dump/NA-Collections-Updates-Downloaded.ps1
Normal file
@@ -0,0 +1,73 @@
|
||||
<#
|
||||
|
||||
Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1'
|
||||
New-PSDrive -Name SCCM-Drive -PSProvider "AdminUI.PS.Provider\CMSite" -Root "PNCRASCCM001.ccx.carecentrix.com" -Description "SCCM Site"
|
||||
|
||||
#>
|
||||
|
||||
$DeviceCollection_Name = "6PM - Production Patching"
|
||||
#$DeviceCollection_Name = "9PM - Production Patching"
|
||||
#$DeviceCollection_Name = "11PM - Production Patching - File Servers"
|
||||
#$DeviceCollection_Name = "11PM - Production Patching"
|
||||
#$DeviceCollection_Name = ""
|
||||
|
||||
$DD = @()
|
||||
$Downloaded_Updates = @()
|
||||
$NOT_Downloaded_Updates = @()
|
||||
$Count = 0
|
||||
[INT]$Last_Writetime = "800" #hours
|
||||
|
||||
|
||||
CD sccm-drive:
|
||||
|
||||
$DeviceCollection_MemberCount = Get-CMDeviceCollection -Name $DeviceCollection_Name | select Name,MemberCount
|
||||
$DeviceCollection_ServerNames = Get-CMCollectionMember -CollectionName $DeviceCollection_Name | select Name,IsClient
|
||||
|
||||
Set-Location c:
|
||||
|
||||
$DeviceCollection_ServerNames.Name | % {
|
||||
$Computer = $_
|
||||
$Check_Contents = gci "\\$Computer\c$\Windows\ccmcache" | ? { $_.lastwritetime -gt ((Get-Date).AddHours((-$Last_Writetime))) }
|
||||
|
||||
If ($Check_Contents) { $Downloaded_Updates += $Computer }
|
||||
Else { $NOT_Downloaded_Updates += $Computer }
|
||||
|
||||
}
|
||||
|
||||
If($Downloaded_Updates) {
|
||||
$Downloaded_Updates | % {
|
||||
$Updates_Downloaded = gci "\\$_\c$\Windows\ccmcache" | ? { $_.lastwritetime -gt ((Get-Date).AddHours((-$Last_Writetime))) }
|
||||
$Obj = New-Object -TypeName PSObject
|
||||
$Obj | Add-Member -MemberType NoteProperty -Name Computer -Value $_
|
||||
$Obj | Add-Member -MemberType NoteProperty -Name LastWriteTime -Value $Updates_Downloaded[-1].LastWriteTime
|
||||
$Obj | Add-Member -MemberType NoteProperty -Name FileName -Value $Updates_Downloaded[-1].Name
|
||||
$Obj | Add-Member -MemberType NoteProperty -Name UpdatesCount -Value ($Updates_Downloaded.count)
|
||||
$Obj
|
||||
}#end%
|
||||
}#endIf
|
||||
Write-Host ""
|
||||
Write-Host "Total Servers in Collection: $($DeviceCollection_MemberCount.MemberCount)" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
Write-Host "Servers Downloaded patches count: $($Downloaded_Updates.count)" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
Write-Host "Total Servers in Collection - $($DeviceCollection_MemberCount.MemberCount)"
|
||||
Write-Host ""
|
||||
Write-Host "Nothing Downloaded for: $($NOT_Downloaded_Updates.count) Servers" -ForegroundColor Yellow
|
||||
|
||||
Write-Host ""
|
||||
|
||||
|
||||
|
||||
<#
|
||||
Write-Host ""
|
||||
Write-Host ""
|
||||
Write-Host "Folder Empty for the following:"
|
||||
Write-Host "$NOT_Downloaded_Updates"
|
||||
|
||||
|
||||
#>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user