| Entity | Display | Description |
| ☐ | ☐ | Ballot box |
| ◻ | ◻ | Empty Box |
| ◻ | ◻ | Empty Box |
| □ | □ | Square |
| □ | □ | Square |
| ☑ | ☑ | Ballot box with check |
| ✓ | ✓ | Check |
| ✓ | ✓ | Check |
| ☒ | ☒ | Ballot box with cross |
| ⊠ | ⊠ | Box with cross |
| ⊠ | ⊠ | Box with cross |
| ✗ | ✗ | Cross |
| ✗ | ✗ | Cross |
Month: August 2020
A sample implementation of windows balloon notification for powershell is as follows:
Add-Type -AssemblyName System.Windows.Forms
function FnShowBalloon {
[CmdLetBinding()]
param($title,
$message,
[string] $icon = 'info',
[int] $delay = 20000,
[int] $sleep=0)
Switch($icon.ToString().ToLower()) {
'warn' {$iconInstance = [System.Windows.Forms.ToolTipIcon]::Warning}
'error' {$iconInstance = [System.Windows.Forms.ToolTipIcon]::Error}
'info' {$iconInstance = [System.Windows.Forms.ToolTipIcon]::Info}
default {$iconInstance = [System.Windows.Forms.ToolTipIcon]::None}
}
$notification = New-Object System.Windows.Forms.NotifyIcon
$path = (Get-Process -id $pid).Path
$notification.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path)
$notification.BalloonTipIcon = $iconInstance
$notification.BalloonTipTitle = $title
$notification.BalloonTipText = $message
$notification.Visible = $true
$notification.ShowBalloonTip($delay)
if ($sleep -gt 0) {
Start-Sleep -s $sleep
$notification.Dispose()
}
}
The FnShowBalloon function can be used as follows:
FnShowBalloon -title "Hello World" -message "This is a sample message" -icon info
It is recommended to have the following command somewhere in the beginning of the powershell script file:
cd /d $PSScriptRoot
The presence of this will run all the commands after it with respect to the location of the running powershell script file.
Instead of using > to redirect the output into a file, pipe it to out-file cmdlet.
The out-file cmdlet allows some useful parameters as follows:
| Parameter | Argument | Description |
| -Append | Adds the output to the end of an existing file. | |
| -Encoding | Encoding | Specifies the type of encoding for the target file. The default value is utf8NoBOM.
The acceptable values for this parameter are as follows: ascii: Uses the encoding for the ASCII (7-bit) character set. |
| -FilePath | Path | Specifies the path to the output file. |
To redirecting the output of the dir command to dir.txt file, use the following command:
dir | out-file -encoding ascii -filepath "dir.txt"
Recent Comments