This is just a quick example of how we can query a Windows Installer using Powershell code: $msiOpenDatabaseModeReadOnly = 0 $msiOpenDatabaseModeTransact = 1 $windowsInstaller = New-Object -ComObject windowsInstaller.Installer $pathToMSI = “C:\Users\xxxx\Desktop\AlkaneExample.msi” $database = $windowsInstaller.GetType().InvokeMember(“OpenDatabase”, “InvokeMethod”, $null, $windowsInstaller, @($pathToMSI, $msiOpenDatabaseModeReadOnly)) $query … Continue reading →
This post provides the benefits of using a Powershell array of hashtables instead of a multidimensional Array. When scripting and coding a solution we’re often required to read from back-end databases. Sometimes if we want to reduce the amount of … Continue reading →
This post provides an example of using PowerShell to databind a combobox with a value and some text. Creating a combobox in Powershell and adding an item to it is a relatively trivial task: $combobox = New-Object System.Windows.Forms.ComboBox $combobox.Items.add(“alkane”) The … Continue reading →
Here’s a quick snippet that details how to get and set custom document properties in Microsoft Word 2010 documents: #Create Word application $wordApplication = New-Object -ComObject word.application #Get reference to word doc $document = $wordApplication.documents.open(“C:\temp\alkane.docx”); #set up binding flags for … Continue reading →
A useful script to set registry key permissions with Powershell. This example gives full control to the built in Users group. $acl = Get-Acl “HKLM:\SOFTWARE\Example” $person = [System.Security.Principal.NTAccount]”BuiltIn\Users” $access = [System.Security.AccessControl.RegistryRights]”FullControl” $inheritance = [System.Security.AccessControl.InheritanceFlags]”ContainerInherit,ObjectInherit” $propagation = [System.Security.AccessControl.PropagationFlags]”None” $type = [System.Security.AccessControl.AccessControlType]”Allow” … Continue reading →
This post will provides an example of how we can use ADSI to check if a user is a member of an AD Group using the [ADSISearcher] type accelerator: #remember that this is used as a regular expression (using -match), … Continue reading →
Dim objShell : Set objShell = CreateObject(“WScript.Shell”) Dim userProfileFolder : userProfileFolder = objShell.ExpandEnvironmentStrings(“%USERPROFILE%”) Dim desktopFolder : desktopFolder = userProfileFolder & “\Desktop” Dim programFilesFolder : programFilesFolder = objShell.ExpandEnvironmentStrings(“%ProgramFiles%”) Dim shortcutName : shortcutName = “Alkane Test” Dim shortcutDescription : shortcutDescription = “Alkane … Continue reading →
Ok. I won’t drag this out too much since there’s FAR too much to comment on. But my aim was to create a web-based upload facility that is compatible with old browsers (such as IE8) and has the ability to … Continue reading →
This is an example of how we can perform Rijndael encryption and decryption in C# and Powershell. It’s worth mentioning that: – salt must be 8 bytes minimum – initVector must be 16 bytes minimum The examples below use Cipher … Continue reading →
This post provides an example of getting the public key token of an assembly using PowerShell. When I need to add definitions to the web.config of my ASP.Net projects I often use this Powershell line to get the PublicKeyToken, Culture … Continue reading →