#these are all the available methods for stdregprov: http://msdn.microsoft.com/en-us/library/aa393664%28v=vs.85%29.aspx

$supportedstdregprovmethods='enumkey','enumvalues','getstringvalue'

#$allstdregprovmethods = 'checkaccess','createkey','deletekey','deletevalue','enumkey','enumvalues','getbinaryvalue','getdwordvalue','getexpandedstringvalue','getmultistringvalue','getstringvalue','setbinaryvalue','setdwordvalue','setexpandedstringvalue','setmultistringvalue','setstringvalue','#these are not supported in windows version 5.x.x (<=2003/xp)','getqwordvalue','getsecuritydescriptor','setqwordvalue','setsecuritydescriptor'

if($supportedstdregprovmethods-notcontains$stdregprovmethod) {

write-host You have provided a StrRegProv Method that is not supported yet.

#then we can just run it as is. It contains the one of the uninstall commands ("/x$productGUID" or "/xproduct.msi") or it could be an EXE or something else [see pdfcreator for an example of this instance].

if($debug) { write-host running "$filePath"}

(Start-Process-FilePath "$filePath"-Wait -Passthru).ExitCode

}

else {

#We'll gather up the switches, then we'll verify each as okay (only allow $silentArgs, except "/x" which requires more things)

# a switch is defined as any string that starts with a '/' that is followed by '[a-zA-Z]' then followed by parameters

# this excludes the /log switch as it can contain a parameter... maybe later...

# we can exclude the `/x` switch from this check as it was already handled in this conditional

$filePath-split"/"|foreach-object {

if($_-ne"x") {

if($silentArgs-match[regex]::Escape($_.trim())) {

[string[]]$matchedsilentargs+=$_

}

}

}

foreach($silentArgin$silentArgs) {

if($silentArg-ne"/x") {

[string[]]$matchedsilentargs+=$silentArg

}

}

#Now, let's add /x$productGUID to $silentArgs. It wasn't already there, or the original condition (above) would have covered it.