Sometimes we’re struggling to write a script need to get help with PowerShell cmdlets, parameters, methods and properties. Here we explain how we can use get-help to assist us. Firstly, it’s useful to know which Cmdlets and functions are available … Continue reading →
Here we explain how to use PowerShell to read and write environment variables, which exist in the user, process and machine contexts. We can read and write environment variables in a variety of ways, but the easiest ways to read … Continue reading →
Here we explain how to use PowerShell to read from a text file, and iterate through it line by line. Consider the following text file called c:\alkane.txt: line 1 line 2 line 3 line 4 line 5 We can simply … Continue reading →
There are a couple of ways of using PowerShell to replace strings. We can use either the Replace() method or the -replace operator. PowerShell String Replacement using the Replace() Method This isn’t my favourite approach to replacing string using PowerShell, … Continue reading →
I recently needed to compare version numbers with PowerShell, so I could deduce which software was superseded by a later version. But it turned out to be a little more complicated than anticipated! In software versioning, I see 14.03.0.0 as … Continue reading →
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 →