There are many occasions where I need to move or copy Active Directory users from one group to another. Usually this occurs when an application has been updated to a new version, and we need to migrate users from the … Continue reading →
This is an example of how to install and uninstall an MSI using PowerShell. It passes in a string array as the msiexec arguments. So you can add more arguments as you see fit. Pay close attention to the quotes … Continue reading →
This is a simple example of using a Hashtable to store key/value pairs. Rather than referencing a value in an array using a numeric index, we now have named (the key) human-readable values that we can use to reference a … Continue reading →
This post provides an example of how we can use ADSI to check if a computer is a member of an AD Group using the [ADSISearcher] type accelerator: #remember that this is used as a regular expression (using -match), so … Continue reading →
This isn’t the most interesting of blog posts admittedly. But I was using the SQL Server Management Objects (SSMO) in my PowerShell script to return a result set from a stored procedure in SQL server. The data set returned from … Continue reading →
This post explains how to export to CSV using PowerShell and dynamic data. I find that hashtables are quite useful for various scenarios when scripting in PowerShell. We can also utilise them when exporting data using Export-CSV. I provide two … Continue reading →
This is just a quick one-liner that I use to get filenames and versions in folders and subfolders. I tend to use it every now and then to compare two folder structures on different machines, and then I can use … Continue reading →
Here’s a small chunk of code from a recent request asking how to write to the Windows Installer binary stream using Powershell: $msiOpenDatabaseModeReadOnly = 0 $msiOpenDatabaseModeTransact = 1 $windowsInstaller = New-Object -ComObject windowsInstaller.Installer $pathToMSI = “C:\Users\xxxx\Desktop\AlkaneExample.msi” $database2 = $windowsInstaller.GetType().InvokeMember(“OpenDatabase”, “InvokeMethod”, … Continue reading →
This post provides an example of how to count members of an AD Group and write to a CSV. This script finds all AD groups beginning with ‘MSI – ‘ or ‘App-V – ‘ and returns the number of members … Continue reading →
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 →