PowerShell: Showing MsgBox

Posted Leave a commentPosted in PowerShell

Ever wanted to display a dialog box from PowerShell rather than spitting out console text? Then try this function: function Show-MsgBox { param ( [Parameter(Mandatory=$true)] [String]$Text, [String]$Title = ‘Message’, [String] $Icon = ‘YesNo,Information’ ) Add-Type -AssemblyName ‘Microsoft.VisualBasic’ [Microsoft.VisualBasic.Interaction]::MsgBox($text, $icon, $title) } It is really easy to use: simply tell it what to display: Show-MsgBox -Text […]

PowerShell: Adding Progress to Long-Running Cmdlets

Posted Leave a commentPosted in PowerShell

Sometimes cmdlets take some time, and unless they emit data, the user gets no feedback. Here are three examples for calls that take a long time without providing user feedback: $hotfix = Get-Hotfix $products = Get-WmiObject Win32_Product $scripts = Get-ChildItem $env:windir *.ps1 -Recurse -ea 0 To provide your scripts with better user feedback, here’s a […]

PowerShell: Executing PowerShell on Computer Lock

Posted 1 CommentPosted in PowerShell

PowerShell can respond to system events such as locking or unlocking a session. Here is a fun sample. Provided you have your sound card turned on, your computer will say good-bye when you press WIN+L and welcome you back when you log on again: function Start-Fun { $null = Register-ObjectEvent -InputObject ([Microsoft.Win32.SystemEvents]) -EventName “SessionSwitch” -Action […]

PowerShell: Script Signing

Posted 2 CommentsPosted in PowerShell

Signing a script doesn’t mean you’re approving or authorizing it, as you might do with a contract or a credit card slip. In the world of digital security, signing is the process of affixing your identity to something and ensuring that the state or condition of that “something” has not been modified in any way. […]

PowerShell: Execution Policy

Posted 1 CommentPosted in PowerShell

The Restricted execution policy is a default setting for all computers with PowerShell installed. It isn’t intended to be something that PowerShell users live with forever. It’s a safe default that protects non PowerShell users from being impacted by PowerShell-based malware. For example, many home users had never used VBScript, but still got bitten by the […]

PowerShell: Remoting

Posted Leave a commentPosted in PowerShell

The Windows PowerShell remoting features are supported by the WS-Management protocol and the Windows Remote Management (WinRM) service that implements WS-Management in Windows. Computers running Windows 7 and later include WinRM 2.0 or later. On computers running earlier versions of Windows, you need to install WinRM 2.0 or later as appropriate and if supported. Currently, […]

PowerShell: Introduction

Posted Leave a commentPosted in PowerShell

PowerShell is a new command shell from Microsoft, based on the Win32 console. It is a command prompt and scripting environment and it can even be both at the same time. To be more precise, Windows PowerShell is Microsoft’s task automation framework, consisting of a command-line shell and associated scripting language built on top of, […]