Created
January 27, 2022 16:34
-
-
Save MarcoGriep88/278eaab7a8878a7d07e3be15767053ba to your computer and use it in GitHub Desktop.
Ivanti DSM - Monitor Job Policies for errors (like pending reboot) - PSX PowerShell Extensions Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Install-Module ImportExcel | |
#Connection Options | |
param | |
( | |
[string]$argServer = 'meinbls.intranet.int:8090', | |
#localhost:8090 | |
[string]$argUser = 'domain\username', | |
#domain\username | |
[string]$argPassword = 'Password123', | |
#Password123 | |
[string]$context = "emdb:\rootDSE\Managed Users & Computers\*" | |
) | |
$subRoutineFlag = 0; #Default = 0 (Change only for debugging) | |
#Prepare PS to Use HEAT DSM | |
import-module psx7 -DisableNameChecking | |
#Create global Authentification | |
$Server = "\\$argServer"; | |
$Username = $argUser; | |
$global:path = $context | |
$password = $argPassword | ConvertTo-SecureString -asPlainText -Force | |
$credential = New-Object System.Management.Automation.PSCredential($Username, $password) | |
Write-Host "Using context: " + $context | |
#Connect to HEAT DSM | |
new-psdrive -name emdb -root $Server -scope script -psprovider blsemdb -Credential $credential | |
emdb: | |
$fileName = "C:\temp\" + (Get-Date).Year.ToString() + "_" + (Get-Date).Month.ToString() + "_" + (Get-Date).Day.ToString() + "_" + (Get-Date).Hour.ToString()+ (Get-Date).Minute.ToString() + (Get-Date).Second.ToString() + "_Jobs.xlsx" | |
$MyJobPolicys = Get-EmdbPolicy "emdb:\rootDSE\Managed Users & Computers\2\. Computers\Patch-Management-Workstations" -PolicyType "JobPolicy" | |
$data = @" | |
Computer,InstallParam,Compliance,isActive,Message | |
"@ | |
foreach($job in $MyJobPolicys) { | |
$instances = $job.GetPolicyInstances(); | |
foreach($i in $instances) { | |
$InstallParam = $i.GetInstallationParameters()[0].Value | |
$ComplianceState = $i.ComplianceState | |
$isActive = $i.IsActive | |
$machine = $i.TargetObjectName | |
$msg = $i.LastComment | |
Write-Host $machine "-" $msg | |
$data += [System.Environment]::NewLine + $machine + "," + $InstallParam + "," + $ComplianceState + "," + $isActive + "," + $msg | |
} | |
} | |
$dataList = $data | ConvertFrom-CSV | |
$dataList | Export-Excel $fileName -Show -AutoSize -IncludePivotTable -PivotRows Compliance -PivotData @{ Computer = "count" } -IncludePivotChart -ChartType PieExploded3D | |
# $computers = Get-EmdbComputer $context -Recurse |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment