0
votes

Let's say I run:

Get-CMDeployment -CollectionName "gar25*" | select CollectionName, ApplicationName, PackageID, DeploymentTime, EnforcementDeadline | out-gridview

enter image description here

This gives me all the info I need on multiple deployments associated to a user, but the value "EnforcementDeadline" is blank, which i'm guessing is a lazy property. How would I retrieve it? I have found this article:

https://trevorsullivan.net/2010/09/28/powershell-configmgr-wmi-provider-feat-lazy-properties/#comment-3628074206

but i'm really struggling to adapt the code.

Thanks a lot for your time.

2
Even if i do something else like : "Get-CMDeployment -CollectionName "abc123*"" on the server it returns similar information. deployment time, modification...but no required and/or expiring, what the...? - Rakha
Haha this is driving me nuts...even on the assignement, if i do for example: Get-WmiObject -ComputerName XXXX-Namespace "ROOT\SMS\site_XXX" -Query "SELECT * FROM SMS_Advertisement WHERE ProgramName='XXXXX'" I see the ExpirationTime but not Required...wow! - Rakha
Just because PowerShell doesn't output a property by default doesn't mean that the object does not contain the property. - Bill_Stewart
How do i extract/display that property ? @Bill_Stewart - Rakha
Even if i do for example : "Get-CMDeployment -CollectionName "abc" | Format-List -Property * | out-file c:\temp\res.txt" I get a ton of other properties but not the assigned / required time... - Rakha

2 Answers

1
votes

EnforcementDeadline is a property for application deployments. You're trying to read it from a package deployment where it doesn't exist because they can have multiple assigned schedules which can be both one time or recurring (ex. daily). If you use Get-CMApplicationDeployment and Get-CMPackageDeployment you will get the right type of objects so you can access the values.

I've included a sample that will detect if the deployment is for a package and retrieve the StartTime-values for it's schedules (I assume they are non-reccuring).

$DeadlineColumn = @{
    Name="EnforcementDeadline"
    Expression={
        if($_.FeatureType -eq 2 -or $_.FeatureType -eq 7) {
            #Package or task sequence
            #Get assignment-starttime (ignoring daily/hourly etc.)
            (Get-CMPackageDeployment -DeploymentId $_.DeploymentID).AssignedSchedule | Select-Object -ExpandProperty StartTime
        } else {
            #Application
            $_.EnforcementDeadline
        }
    }
}

Get-CMDeployment -CollectionName "abc" | select CollectionName, ApplicationName, PackageID, DeploymentTime, $DeadlineColumn | out-gridview
0
votes

@Frode F. I can't being to thank you enough, this is so perfect and time saving. Here is my final solution:

$DeadlineColumn = @{
    Name="EnforcementDeadline"
    Expression={
        if($_.FeatureType -eq "2" -or $_.FeatureType -eq "TaskSequence") {

            (Get-CMPackageDeployment -DeploymentId $_.DeploymentID).AssignedSchedule | Select-Object -ExpandProperty StartTime
        } else {
            (Get-CMTaskSequenceDeployment -DeploymentId $_.DeploymentID).AssignedSchedule | Select-Object -ExpandProperty StartTime
        }
    }
}


$ExpirationColumn = @{
    Name="ExpirationTime"
    Expression={
        if($_.FeatureType -eq "2" -or $_.FeatureType -eq "TaskSequence") {

            (Get-CMPackageDeployment -DeploymentId $_.DeploymentID).ExpirationTime 
        } else {
             (Get-CMTaskSequenceDeployment -DeploymentId $_.DeploymentID).ExpirationTime 
        }
    }
}

Get-CMDeployment -CollectionName "gar25*" | select CollectionName, ApplicationName, PackageID, DeploymentTime, $DeadlineColumn, $ExpirationColumn | out-gridview

Which returns all times for packages and deployments!

enter image description here