This article explain how to test whether parts of the registry structure exist for a user.
The following will test if a key exists in the registry:
Test-path “HKCU:\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles”
This will return either True or False
You can also do this to see if a property exists in the key as below:
Test-path “HKCU:\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\DefaultProfile”
Using an IF statement it allows us to run a program off the back of the result, as seen below:
$RegPath = Test-path “HKCU:\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\DefaultProfile”
#$OutlookPath = “C:\Program Files (x86)\Microsoft Office\Office14\OUTLOOK.EXE /importprf \\fileservername\ExchangeOutlook_PRF\exchange2007.prf”
If ($RegPath -eq $True)
{Write-host “No Outlook Profile”}
else
{start-process -filepath “C:\Program Files (x86)\Microsoft Office\Office14\OUTLOOK.EXE”}
No comments yet... Be the first to leave a reply!