Environment:
- System Center Configuration Manager 1810
- Workstations = Windows 10 1709 / Windows 7 SP1
- Application spécific with add-on script to accomplish the tasks
Way to accomplish it:
- Deploy package without licence
Push licence file
- Stop service
- Read licence with SCCM tack and push it if necessary
- Start service
Hundreds of computers are affected and the editor doesn't submit a guideline to accomplish it without rebooting computers without prompting end-users.
We are using SCCM to deploy and check packages (WMI query, registry, ...). We can use, powershell to query more objects, like reading the licence file to check if it is the good one.
Reading licence is done this way:
if ((Get-Content "C:\Program Files\XXX\X.LIC") -contains serial_no=XXXXX")) {
Write-Host "License OK"
}
If the licence, isn't the good one, a little is launched on the workstation (somewhere in a folder like C:\Windows\CCMCACHE\a) like
If (Test-Path ("C:\Program Files (x86)\NetSupport\NetSupport School"))
{
If (Test-Path ("C:\Program Files (x86)\XXX\X.LIC"))
{
Rename-Item -Path "C:\Program Files (x86)\XXX\X.LIC" -NewName ("X.LIC." + (Get-Date).ToString("yyyyMMdd")) -Force
}
Copy-Item -Source $PSScriptRoot\X.LIC -Destination ("C:\Program Files (x86)\XXX") -Force
}
ElseIf(Test-Path ("C:\Program Files\XXX"))
{
If (Test-Path ("C:\Program Files\XXX\X.LIC"))
{
Rename-Item -Path "C:\Program Files\XXX\X.LIC" -NewName ("X.LIC." + (Get-Date).ToString("yyyyMMdd")) -Force
}
Copy-Item -Source $PSScriptRoot\X.LIC -Destination ("C:\Program Files\XXX") -Force
}
Do I need PowerShell v3? How can i do it with PSv2 ?