Jan 17 2022 07:10 AM
Hi all
New to Intune .. and in trouble. 🙂
I need to check if some registrykeys exists on devices, and then dynamically add/remove devices to/from a group if the key exists. How can this be done?
In SCCM I would create a configuration baseline and add the resulting devices to a collection .. but .. no configuration baselines or collections exists in InTune. 🙂
A hint please.
Jan 17 2022 08:01 AM
Jan 17 2022 09:27 AM
Jan 17 2022 10:11 AM
Jan 17 2022 10:11 AM - edited Jan 17 2022 10:13 AM
Solution
- Publish the app to all machines
- Use a detection script in the with something like this:
if ((Get-ItemProperty -Path HKLM:\SOFTWARE\Company\App).Version -eq '1.2') {
if (test-path -Path 'C:\Program Files\Company\App\app.exe') {
write-host Company App key found with version 1.2 and software is installed
exit 0
}
else {
write-host Company app key found with version 1.2 but software is not installed
exit 1
}
}
if (-not (Get-ItemProperty -Path HKLM:\SOFTWARE\Company\App).Version -eq '1.2') {
write-host Company App key not found so no need to install software
exit 0
}
So.. If the specific key exists, the one that you want to detect if installation of the software is needed, then it will check for the software by checking the path in c:\program files. If it's not there, it will report it and exit with exit code 1. That way it will know it will have to install the software.
If the specific key doesn't exist on the system, it will exit with exit code 0 telling Intune that the software is installed (Not needed actually, but you know what I mean 😉 )
And like Rudy Ooms said, if the specific key is not there.. You can also create it, I read it like you already had that key present to specify a certain type of machine
Jan 17 2022 10:13 AM
Jan 17 2022 10:16 AM
Jan 18 2022 05:16 AM
Jan 17 2022 10:11 AM - edited Jan 17 2022 10:13 AM
Solution
- Publish the app to all machines
- Use a detection script in the with something like this:
if ((Get-ItemProperty -Path HKLM:\SOFTWARE\Company\App).Version -eq '1.2') {
if (test-path -Path 'C:\Program Files\Company\App\app.exe') {
write-host Company App key found with version 1.2 and software is installed
exit 0
}
else {
write-host Company app key found with version 1.2 but software is not installed
exit 1
}
}
if (-not (Get-ItemProperty -Path HKLM:\SOFTWARE\Company\App).Version -eq '1.2') {
write-host Company App key not found so no need to install software
exit 0
}
So.. If the specific key exists, the one that you want to detect if installation of the software is needed, then it will check for the software by checking the path in c:\program files. If it's not there, it will report it and exit with exit code 1. That way it will know it will have to install the software.
If the specific key doesn't exist on the system, it will exit with exit code 0 telling Intune that the software is installed (Not needed actually, but you know what I mean 😉 )
And like Rudy Ooms said, if the specific key is not there.. You can also create it, I read it like you already had that key present to specify a certain type of machine