Archive | May, 2012

PowerShell: Adding More Fonts

Tired of using the boring default fonts in PowerShell? There are more monospaced fonts on your system. You just need to allow the console to use them. Here’s how: $key = ‘HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont’ Set-ItemProperty -Path $key -Name ‘0’ -Value ‘Lucida Console’ Set-ItemProperty -Path $key -Name ’00’ -Value ‘Courier New’ Set-ItemProperty -Path $key -Name ‘000’ -Value […]

Continue Reading →

PowerShell: Check Active Internet Connection

If your machine is connected to the Internet more than once, let’s say cabled and wireless at the same time, which connection is used? Here’s a function that tells you: function test-ipmetric { Get-WmiObject Win32_NetworkAdapter -Filter “AdapterType=’Ethernet 802.3′” | ForEach-Object { $_.GetRelated(‘Win32_NetworkAdapterConfiguration’) } | Select-Object Description, Index, IPEnabled, IPConnectionMetric }

Continue Reading →

PowerShell: More Can Be Dangerous

You might know the more.com tool: when you pipe output to more.com, the output is displayed page by page: PS> Get-EventLog -LogName System | more However, more can be dangerous as you see here. You will not get any results for a long time, and your CPU load increases. more.com first collects all results before […]

Continue Reading →

PowerShell: Sending Emails Securely (via SSL)

Here is a sample that uses the live.com freemailer (formally called Hotmail) which does require a secure connection: PS> Send-MailMessage -Body ‘My mail message can contain special characters: äöüß’ -From youraccountname@hotmail.com -to someone@somewhere.com -Credential youraccountname@hotmail.com -SmtpServer smtp.live.com -Subject ‘Sending Mail from PowerShell’ -Encoding UTF8 -UseSsl Note that PowerShell v3 Send-MailMessage accepts UTF8 directly so you […]

Continue Reading →

PowerShell: Analysing System Restarts

To find out when a system restarted and why, use the below code to extract the relevant information from the System event log: Get-EventLog -LogName System -ComputerName Server1 | where {$_.EventId -eq 1074} | ForEach-Object { $rv = New-Object PSObject | Select-Object Date, User, Action, Process, Reason, ReasonCode, Comment, Message if ($_.ReplacementStrings[4]) { $rv.Date = […]

Continue Reading →
revia in alcoholism