Thx for your reply dotnVo
I do agree on many statements you wrote. My point about “upgrade” is not an answer is that the work i’m doing right now is just to save me time, the client i’m wokring for has no time, budget whatsoever to upgrade to another version and he perfectly understands that running an outdated version of a software might cost him later more than what he expects to save right now (you know… all the clients are the same )
Anyway, i think i solved my issue but nevertheless, i’m gonna share and answer just because you also spend some time to reply my post.
So 1st of all, the version of Configuration Manager i’m using is 2012 R2 SP1 and the version of the ConfigurationManager module that it comes with is 5.0.8231.1004
Just like you, i’m pretty sure the only way to have a more recent version of that module would be to upgrade SCCM. That being said, the module also comes with the SCCM Admin Client. So, maybe i’ll try to check if a newer version of the Admin console might work with an older version of the SCCM server itself.
Anyway, as i said, when i import the module and check the avaiable cmdlet for that module (Get-Command -Module ConfigurationManager), clearly the cmdlet New-CMPackageDeployment doesn’t exist.
Funny thing is that New-CMPackage does exist because i’ve been able to create my package with this.
So i started to look around the cmdlet “Start-CMPackageDeployment” which seems to operate in the same direction. My goal being to deploy a program from a package to a specific collection group target at a specific time. Nothing fancy.
You’re right, the code i copied above was not accurate and i missed the latest test i performed with the correct variables so that none of them are considered as null.
as i said, i found the bottom line why my command failed and it was that i missed the parameter “-StandardProgram”, pretty much everything else was in place. i can’t recall the error message i had at that time but it was a generic PowerShell error, something like “unable to process the cmdlet” (as it was written in french i’m not even sure how to translate this)
So in the end, deployment was created successfuly, i have a very very few parameters that seems not possible to tweak via the version of the module i’m using but i’m pretty pleased with the final result anyway
So here’s the final code :
$CollectionName = "TargetCollection Test #1"
$ProgramName = "Dummy Prg"
$packageName = "Dummy Package"
$deploymentStartTime = get-date 08/02/2024 -hour 16 -Minute 30 -Second 00
$deployPurpose = "Required"
$useUTC = $false
$RerunBehavior = "AlwaysRerunProgram"
$RunPolicy = "RunProgramFromDistributionPoint"
$DeploymentSchedule = New-CMSchedule -Start $deploymentStartTime -Nonrecurring
Start-CMPackageDeployment -CollectionName $CollectionName -PackageName $packageName -StandardProgram -StandardProgramName $ProgramName -DeployPurpose $deployPurpose -Schedule $DeploymentSchedule -Comment "Generated via PowerShell script" -SlowNetworkOption $RunPolicy -FastNetworkOption $RunPolicy -RerunBehavior $RerunBehavior -AllowSharedContent $false
Hope that it could also help people in the same situation.