Monthly Archives: October 2011

Reading the hosts file–revised

Quick revision to the post on reading the hosts file http://msmvps.com/blogs/richardsiddaway/archive/2011/10/23/reading-the-hosts-file.aspx. I wanted to be able to display the whole file function get-hostfilecontent { param ([switch]$all) $file = Join-Path -Path $($env:windir) -ChildPath “system32\drivers\etc\hosts” if (-not (Test-Path -Path $file)){ Throw “Hosts … Continue reading

Posted in Networking, PowerShell V2 | Leave a comment

Multiple value query in WQL

A simple query that demonstrates how to query for multiple values. We want to stop the running services that are running where the names a like BITS and WinRm Get-WmiObject -Class Win32_Service -Filter “State=’Running’ AND Name LIKE ‘%BITS%’ OR Name … Continue reading

Posted in PowerShell and WMI | Leave a comment

Logging non-contactable systems

In this post – http://msmvps.com/blogs/richardsiddaway/archive/2011/10/23/1760058.aspx – I showed how to get the date of the last update applied to a system.  A comment was posted asking how to log machines that can’t be contacted “.”, “rslaptop01”, “200.0.0.1” | foreach { … Continue reading

Posted in PowerShell and WMI | Leave a comment

Clearing hosts file

We seen how to delete a single entry from the hosts file – this is how we clear all entries function clear-hostfilecontent { [CmdletBinding()] param () $file = Join-Path -Path $($env:windir) -ChildPath “system32\drivers\etc\hosts” if (-not (Test-Path -Path $file)){ Throw “Hosts … Continue reading

Posted in Networking, PowerShell V2 | Leave a comment

PowerShell, Storage, WMI and Windows Server 8

A must read if you are interested in any of these http://blogs.technet.com/b/server-cloud/archive/2011/10/14/windows-server-8-standards-based-storage-management.aspx   WMI is getting everywhere these days – better learn it quick

Posted in PowerShell and WMI, PowerShell V3, Windows 8 Server | Leave a comment

Remove a host file record

Next up is removing a record from a hosts file function remove-hostfilecontent { [CmdletBinding()] param ( [parameter(Mandatory=$true)] [ValidatePattern(“\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b”)] [string]$IPAddress, [parameter(Mandatory=$true)] [string]$computer ) $file = Join-Path -Path $($env:windir) -ChildPath “system32\drivers\etc\hosts” if (-not (Test-Path -Path $file)){ Throw “Hosts file not found” } … Continue reading

Posted in Networking, PowerShell V2 | Leave a comment

Minor rant

Why do software suppliers – Adobe with Acrobat Reader & Oracle with Java are the worst culprits – insist on trying to install their browser toolbar & change my default search engine?? What’s worse is that they make the default … Continue reading

Posted in Rant | 1 Comment