PowerShell: Check Windows License Status

In PowerShell, you can directly access the raw licensing data like this: PS> Get-WmiObject SoftwareLicensingService You can also check the license status of your copy of Windows: PS> Get-WmiObject SoftwareLicensingProduct | Select-Object -Property Description, LicenseStatus | Out-GridView And you can find out which Windows SKU you are actually using: PS> Get-WmiObject SoftwareLicensingProduct | Where-Object {…

Continue Reading

PowerShell: Downloading Files from Internet

PowerShell v3 comes with a hugely useful new cmdlet called Invoke-WebRequest. You can use it to interact with websites which also includes downloading files. This will download the SysInternals suite of tools to your computer: $Source = ‘http://download.sysinternals.com/files/SysinternalsSuite.zip’ $Destination = “$env:temp\sysinternalssuite.zip” Invoke-WebRequest -uri $Source -OutFile $Destination Unblock-File $Destination Since downloaded files are blocked by Windows,…

Continue Reading

PowerShell: Finding Process Owners and Sessions

Get-Process returns a lot of information about running tasks but it does not return the process owners or the session a process is logged on to. There are built-in console tools like tasklist that do provide this information. By asking these tools to output their information as comma-separated values, PowerShell can pick up the information…

Continue Reading

PowerShell: Displaying Balloon Tip

Let’s assume your script wants to share status information via a balloon message in the system tray area. Here is a sample: [system.Reflection.Assembly]::LoadWithPartialName(‘System.Windows.Forms’) | Out-Null $balloon = New-Object System.Windows.Forms.NotifyIcon $path = Get-Process -id $pid | Select-Object -ExpandProperty Path $icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path) $balloon.Icon = $icon $balloon.BalloonTipIcon = ‘Info’ $balloon.BalloonTipText = ‘Completed Operation’ $balloon.BalloonTipTitle = ‘Done’ $balloon.Visible…

Continue Reading

PowerShell: Extracting Icons

To extract an icon from a file, use .NET Framework methods. Here is a sample that extracts all icons from all exe files in your Windows folder (or one of its subfolders) and puts them into a separate folder: [System.Reflection.Assembly]::LoadWithPartialName(‘System.Drawing’) | Out-Null $folder = “$env:temp\icons” md $folder -ea 0 | Out-Null dir $env:windir *.exe -ea…

Continue Reading