I recently needed a quick PowerShell script to uninstall windows updates based on date. In the example below, i wanted to uninstall any Windows Updates that had been installed on or after 01/01/2022. cls $ListOfHotfixes = Get-HotFix | Select hotfixid,description,installedby,@{label=”InstalledOn”;e={[DateTime]::Parse($_.psbase.properties[“installedon”].value,$([System.Globalization.CultureInfo]::GetCultureInfo(“en-US”)))}} … Continue reading →
This post explains how we can use PowerShell to restore deleted computer objects from the Active Directory recycle bin. I usually try to manipulate Active Directory using ADSI, because it doesn’t rely on the Active Directory PowerShell cmdlets. However in … Continue reading →
Sometimes we need to find the current logged on username from a system context. For example, consider I have the following two domain user accounts: alkaneuser (standard permissions) alkaneadmin (administrator permissions) If I log into the machine as alkaneuser, and … Continue reading →
In this blog we provide a solution that enables administrators to run PowerShell scripts silently. Many of us have tried to launch Powershell.exe silently with the following parameter: Powershell.exe -WindowStyle Hidden… But we still see a flash of the blue … Continue reading →
The mechanism of installing fonts with PowerShell works slightly differently since the Windows 10 1809 feature update. Previously we could use this one-liner: (New-Object -ComObject Shell.Application).Namespace(0x14).CopyHere(“C:\Build\Font\A39WB_.TTF”,0x14); But since 1809 this installs the font to the per-user location as opposed to … Continue reading →
I recently wanted to run some PowerShell code remotely, but a requirement of this is that WinRM is enabled on the remote device. So we needed to work out how to enable windows remote management (WinRM) on remote devices….without using … Continue reading →
When using Test-Path to query the HKEY_USERS (or HKU) hive, it kept returning false even if the hive existed. This post explains how to use Test-Path for HKEY_USERS, and the modifications that we need to make. How to use Test-Path for … Continue reading →
LDAP does not return all Active Directory group members if there are more than 1500 members in the group. It will return the first 1500, but none thereafter. LDAP Does Not Return All Active Directory Group Members Luckily when a … Continue reading →
This post discusses how we can search Active Directory using ADSISearcher filters. Using search filters can improve search performance significantly. Consider the following where we create a default ADSISearcher to begin searching Active Directory (AD): $objSearcher=[adsisearcher]”” If we used this … Continue reading →
This post provides a simple example of how we can export data to a CSV and maintain the column order: $csvFile = “c:\temp\alkane.csv” $exampledata = @(@(“John”,”37″),@(“Peter”,”14″),@(“Michelle”,”22″),@(“Abdul”,”31″),@(“Roger”,”22″),@(“Rachel”,”50″)) $csvwrapper = @() foreach($person in $exampledata) { $name = $person[0] $age = $person[1] #append … Continue reading →