SCCM 2012: Get Locked Apps/Packages
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | $query = " SELECT SEDO_LockState.LockStateID, SEDO_LockState.AssignedUser, SEDO_LockState.AssignmentTime, SEDO_LockState.AssignedUser, SEDO_LockState.AssignedMachine, v_SmsPackage.Name, fn_ListApplicationCIs.DisplayName, fn_ListApplicationCIs.Manufacturer FROM SEDO_LockState INNER JOIN SEDO_LockableObjects ON SEDO_LockState.LockID = SEDO_LockableObjects.LockID INNER JOIN SEDO_LockableObjectComponents ON (SEDO_LockableObjects.ObjectID = SEDO_LockableObjectComponents.ObjectID) LEFT OUTER JOIN v_SmsPackage ON SEDO_LockableObjectComponents.ComponentID = v_SmsPackage.SEDOComponentID LEFT OUTER JOIN CI_ConfigurationItems ON SEDO_LockableObjectComponents.ComponentID = CI_ConfigurationItems.SEDOComponentID LEFT OUTER JOIN fn_ListApplicationCIs(1033) ON CI_ConfigurationItems.CI_UniqueID = fn_ListApplicationCIs.CI_UniqueID WHERE (SEDO_LockState.LockStateID <> 0)" $server = "" $db = "" $constring = "Server=$server;Database=$db;Integrated Security=True" $connection = New-Object System.Data.SqlClient.SqlConnection $connection .ConnectionString = $constring $connection .Open() $command = $connection .CreateCommand() $command .CommandText = $query $result = $command .ExecuteReader() $table = New-Object System.Data.DataTable $table .Load( $result ) $connection .Close() $table .Rows | Format-Table |