Title: cannot add a snippet
Last modified: August 22, 2016

---

# cannot add a snippet

 *  [christiang79](https://wordpress.org/support/users/christiang79/)
 * (@christiang79)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/cannot-add-a-snippet/)
 * I would like to add following snipped
 *     ```
       function get-msiinfo
       <#
       .SYNOPSIS
       funktion to get MSI details
       .DESCRIPTION
       get ProductCode, ProductVersion, ProductName
       .PARAMETER $Path
       specifies the path of MSI file
       .PARAMETER $Property
       Properies can be specified for ProductCode, ProductVersion, ProductName
       .EXAMPLE
       get-msiinfo -Path C:\temp\file.msi -Property ProductCode
       get-msiinfo -Path C:\temp\file.msi -Property ProductVersion
       get-msiinfo -Path C:\temp\file.msi -Property ProductName
       #>
           {
           [CmdletBinding()]
           param(
               [parameter(Mandatory=$true)]
               [IO.FileInfo]$Path,
               [parameter(Mandatory=$true)]
               [ValidateSet("ProductCode","ProductVersion","ProductName")]
               [string]$Property
               )
           try {
               $WindowsInstaller = New-Object -ComObject WindowsInstaller.Installer
               $MSIDatabase = $WindowsInstaller.GetType().InvokeMember("OpenDatabase","InvokeMethod",$Null,$WindowsInstaller,@($Path.FullName,0))
               $Query = "SELECT Value FROM Property WHERE Property = '$($Property)'"
               $View = $MSIDatabase.GetType().InvokeMember("OpenView","InvokeMethod",$null,$MSIDatabase,($Query))
               $View.GetType().InvokeMember("Execute", "InvokeMethod", $null, $View, $null)
               $Record = $View.GetType().InvokeMember("Fetch","InvokeMethod",$null,$View,$null)
               $Value = $Record.GetType().InvokeMember("StringData","GetProperty",$null,$Record,1)
               return $Value
               }
           catch {
               Write-Output $_.Exception.Message
               }
           }
       ```
   
 * The error appearing shows following:
 * > Access denied by security policy
   >  Your request is blocked by a security policy
   > rule.
 * What causes the error.
 * [https://wordpress.org/plugins/code-snippet-library/](https://wordpress.org/plugins/code-snippet-library/)

The topic ‘cannot add a snippet’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/code-snippet-library_92e341.svg)
 * [Code Snippet Library](https://wordpress.org/plugins/code-snippet-library/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-snippet-library/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-snippet-library/)
 * [Active Topics](https://wordpress.org/support/plugin/code-snippet-library/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-snippet-library/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-snippet-library/reviews/)

## Tags

 * [denied](https://wordpress.org/support/topic-tag/denied/)
 * [policy](https://wordpress.org/support/topic-tag/policy/)

 * 0 replies
 * 1 participant
 * Last reply from: [christiang79](https://wordpress.org/support/users/christiang79/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/cannot-add-a-snippet/)
 * Status: not resolved