Files
Sandbox/SCCM-AutomationDashboard.ps1
T
Zack Meier 03dba08135 sync
2026-04-15 15:42:41 -05:00

35 lines
1.2 KiB
PowerShell

$func = {
Import-Module "D:\Program Files\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1"
Set-Location ITD:\
switch ((Get-Date).Day) {
{ $_ -ge 10 -and $_ -le 19 } {
$CollectionName = 'All-MW-Monthly, 1st Thursday After 2nd Tuesday'
$Platform = 'Test'
}
{ $_ -ge 20 -and $_ -le 31 } {
$CollectionName = 'All-MW-Monthly, 2nd Sunday After 2nd Tuesday'
$Platform = 'Production'
}
Default {
$CollectionName = $null
Exit
}
}
$PlatformStr = "SCCM-MicrosoftUpdates-" + $Platform + "Servers"
Get-CMDevice -CollectionName $CollectionName | Select-Object Name, @{n = 'DashboardPlatform'; e = { $PlatformStr } }
}
$servers = (Invoke-Command -ScriptBlock $func -ComputerName itdsccmp2.nd.gov -Credential $PrvCred)
$postParams = [PSCustomObject]@{
AutomationName = "Infra-Servers-SCCM";
Action = "Patching";
Units = [int][math]::round($servers.count * 7, 0);
Platform = ($servers | Select-Object -First 1).DashboardPlatform;
}
Invoke-RestMethod -Uri http://itdnettools.nd.gov/services/automation-tracking.py -Method POST -Body ($postParams | ConvertTo-Json)