PowerShell for Windows Admins


June 21, 2011  2:40 PM

Rescheduled UG meeting

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Apologies for rescheduling with no notice but my broadband router failed tonight.


When: Thursday, Jun 30, 2011 7:30 PM (BST)


Where: Live Meeting

*~*~*~*~*~*~*~*~*~*

Re-scheduled – using PowerShell to automate Office including Word, Excel, OneNote, Visio and Access

Notes


Richard Siddaway has invited you to attend an online meeting using Live Meeting.
Join the meeting.
Audio Information
Computer Audio
To use computer audio, you need speakers and microphone, or a headset.
First Time Users:
To save time before the meeting, check your system to make sure it is ready to use Microsoft Office Live Meeting.
Troubleshooting
Unable to join the meeting? Follow these steps:

  1. Copy this address and paste it into your web browser:
    https://www.livemeeting.com/cc/usergroups/join
  2. Copy and paste the required information:
    Meeting ID: WNGBC8
    Entry Code: k&w2kpF8d
    Location: https://www.livemeeting.com/cc/usergroups

If you still cannot enter the meeting, contact support

Notice
Microsoft Office Live Meeting can be used to record meetings. By participating in this meeting, you agree that your communications may be monitored or recorded at any time during the meeting.

June 21, 2011  2:09 PM

PowerShell UK user group: apologies

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

My apologies to anyone who tried to connect to the PowerShell UK UG Live Meeting tonight. My broadband router stopped working, permanently, today and I didn’t find out until I got home from work.

By the time I’d tracked down the problem, installed and configured a new router it was well past the meeting finish time.

Apologies for an unavoidable problem.

I’ll re-schedule the meeting for next week.


June 18, 2011  4:06 AM

PowerShell resources: Tip of the Day

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Have a look at the RSS feed available from http://powershell.com/cs/blogs/tips/

There are some good ideas in the tips and if nothing else it will get you thinking about PowerShell


June 17, 2011  12:38 PM

PowerShell User group–topics

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

I’m starting to think about next years programme for the UK user group.

Are there any topics – IT Pro or Dev orientated that you would like to see?

Any speakers you would like me to try and get back?

Do you want more introductory level sessions to cover the basics, high level sessions or the usual mixture?

The sessions will be over Live Meeting still dues to restrictions on facilities

 

Please reply by leaving a comment on this blog post

 

Thank you


June 16, 2011  1:26 PM

root\wmi – WmiMonitorColorCharacteristics

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

The rather long winded name of this class might put you off but it does show something useful

Get-WmiObject -Namespace root\wmi -Class WmiMonitorColorCharacteristics

produces these results (dropping the system properties)

Active           : True
Blue             : System.Management.ManagementBaseObject
DefaultWhite     : System.Management.ManagementBaseObject
Green            : System.Management.ManagementBaseObject
InstanceName     : DISPLAY\LGD6301\5&21e3487a&0&UID33554704_0
Red              : System.Management.ManagementBaseObject

As we have to drill down into these other objects we will create a function

function get-monitorColourCharacteristics {

$monitor = Get-WmiObject -Namespace root\wmi -Class WmiMonitorColorCharacteristics

$colours = New-Object -TypeName PSObject -Property @{
  Monitor = $monitor.InstanceName
  Active = $monitor.Active
}
$colours |
Add-Member -MemberType NoteProperty -Name "White XY" -Value @($monitor.DefaultWhite.X, $monitor.DefaultWhite.Y ) -PassThru |
Add-Member -MemberType NoteProperty -Name "Red XY" -Value @($monitor.Red.X, $monitor.Red.Y ) -PassThru |
Add-Member -MemberType NoteProperty -Name "Green XY" -Value @($monitor.Green.X, $monitor.Green.Y ) -PassThru |
Add-Member -MemberType NoteProperty -Name "Blue XY" -Value @($monitor.Blue.X, $monitor.Blue.Y )

$colours

}

The XY values are explained in these articles

http://en.wikipedia.org/wiki/International_Commission_on_Illumination

http://en.wikipedia.org/wiki/CIE_1931_color_space


June 16, 2011  11:03 AM

New MEAP release for PowerShell and WMI

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Chapters 10 and 11 have been added to the PowerShell and WMI early access release – www.manning.com/siddaway2

Chapter 10 is about printers and it covers:

  • discovering printer configurations;
  • testing printer status;
  • discovering and comparing printer drivers;
  • managing printers;
  • administering print jobs; and
  • testing printers.

Chapter 11 dives into the details of networking:

  • discovering network adapters and their configuration;
  • discovering active protocols;
  • configuring static IP addresses and other TCP/IP settings;
  • enabling DHCP on the adapter;
  • managing DNS and WINS settings in the TCP/IP properties; and
  • displaying the IPv4 routing table.

The code for these and all earlier chapters is available for download.
What’s Next?
In Chapter 12, we will look at managing IIS.


June 15, 2011  12:53 PM

root\wmi–Monitor information

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Continuing our intermittent browse through the root\wmi namespace we find a set of classes that seem to be linked to monitors

Get-WmiObject -Namespace root\wmi -List WmiMonitor*

WmiMonitorBrightnessEvent
WmiMonitorConnectionParams
WmiMonitorRawEEdidV1Block
WmiMonitorListedFrequencyRanges
WmiMonitorDigitalVideoInputParams
WmiMonitorAnalogVideoInputParams
WmiMonitorID
WmiMonitorBrightnessMethods
WmiMonitorBasicDisplayParams
WmiMonitorColorCharacteristics
WmiMonitorDescriptorMethods
WmiMonitorListedSupportedSourceM…
WmiMonitorBrightness
WmiMonitorColorXYZinCIE
WmiMonitorSupportedDisplayFeatures

 

WmiMonitorBasicDisplayParams   seems like a good place to start

Get-WmiObject -Namespace root\wmi -Class WmiMonitorBasicDisplayParams

produces

Active                        : True
DisplayTransferCharacteristic : 120
InstanceName                  : DISPLAY\LGD6301\5&21e3487a&0&UID33554704_0
MaxHorizontalImageSize        : 34
MaxVerticalImageSize          : 19
SupportedDisplayFeatures      : System.Management.ManagementBaseObject
VideoInputType                : 1

 

The supporteddisplayfeatures we need to dig into a bit

$monitor = Get-WmiObject -Namespace root\wmi -Class WmiMonitorBasicDisplayParams
$monitor.SupportedDisplayFeatures

ActiveOffSupported     : False
DisplayType            : 1
GTFSupported           : False
HasPreferredTimingMode : True
sRGBSupported          : False
StandbySupported       : False
SuspendSupported       : False

 

For interest sake the screen resolution of this monitor is 1366 x 768

We can calculate the approximate monitor size – which is the diagonal size – the max horizontal and vertical image sizes are truncated to the nearest centimeter. I think in inches so I want to convert

function get-monitorsize {
Get-WmiObject -Namespace root\wmi -Class WmiMonitorBasicDisplayParams |
select  @{N="Computer"; E={$_.__SERVER}},
InstanceName,
@{N="Horizonal"; E={[System.Math]::Round(($_.MaxHorizontalImageSize/2.54), 2)}},
@{N="Vertical"; E={[System.Math]::Round(($_.MaxVerticalImageSize/2.54), 2)}},
@{N="Size";
E={[System.Math]::Round(([System.Math]::Sqrt([System.Math]::Pow($_.MaxHorizontalImageSize, 2) `
+ [System.Math]::Pow($_.MaxVerticalImageSize, 2))/2.54),2)}}
}

A little bit of pythagoras theorem and division by 2.54 gives me results I can understand.


June 14, 2011  11:12 AM

Scripting Guy Blog- PowerShell and WMI

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

The Scripting Guy is running a series of posts this week featuring articles taken from PowerShell books published by Manning (www.manning.com). Yesterday was Don Jones’ PowerShell Lunches, today is my PowerShell and WMI

Read the articles and get the code for a substantial reduction in the price of the books

See http://blogs.technet.com/b/heyscriptingguy/archive/2011/06/14/use-powershell-to-simplify-access-to-wmi-data.aspx

for the article.


June 13, 2011  3:06 PM

Calculated Fields

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

You have probably seen something like this many times

Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=3" |
select @{Name="FreeSpace";Expression={$_.Freespace / 1GB}}

We take an object and perform a calculation to in effect make a new property – a calculated field. Label can be used instead of Name if desired in PowerShell 2

This can also be done in Format-Table

Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=3" |
Format-Table @{Name="FreeSpace";Expression={$_.Freespace / 1GB}}

There some other parameters we can use

We can control the alignment in the field

Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=3" |
Format-Table @{Name="FreeSpace";Expression={$_.Freespace / 1GB}; Alignment="Left"}

Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=3" |
Format-Table @{Name="FreeSpace";Expression={$_.Freespace / 1GB}; Alignment="Center"}

Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=3" |
Format-Table @{Name="FreeSpace";Expression={$_.Freespace / 1GB}; Alignment="Right"}

We can format the string

Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=3" |
Format-Table @{Name="FreeSpace";Expression={$_.Freespace / 1GB}; Format="F2"; Alignment="Left"}

Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=3" |
Format-Table @{Name="FreeSpace";Expression={$_.Freespace / 1GB}; Format="F2"; Alignment="Center"}

Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=3" |
Format-Table @{Name="FreeSpace";Expression={$_.Freespace / 1GB}; Format="F2"; Alignment="Right"}

And we can control the width of the string

Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=3" |
Format-Table @{Name="FreeSpace";Expression={$_.Freespace / 1GB}; Width=11; Format="F2"; Alignment="Left"}

Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=3" |
Format-Table @{Name="FreeSpace";Expression={$_.Freespace / 1GB}; Width=11; Format="F2"; Alignment="Center"}

Get-WmiObject -Class Win32_LogicalDisk -Filter "DriveType=3" |
Format-Table @{Name="FreeSpace";Expression={$_.Freespace / 1GB}; Width=11; Format="F2"; Alignment="Right"}

 

Width, format and alignment don’t work with select-object


June 12, 2011  1:45 PM

PowerShell User Group–21 June 2011

Richard Siddaway Richard Siddaway Profile: Richard Siddaway


When: Tuesday, Jun 21, 2011 7:30 PM (BST)


Where: Virtual

*~*~*~*~*~*~*~*~*~*

Session will look at using PowerShell to automate Microsoft Office – Word, Excel, Visio, Access and more

Notes


Richard Siddaway has invited you to attend an online meeting using Live Meeting.
Join the meeting.
Audio Information
Computer Audio
To use computer audio, you need speakers and microphone, or a headset.
First Time Users:
To save time before the meeting, check your system to make sure it is ready to use Microsoft Office Live Meeting.
Troubleshooting
Unable to join the meeting? Follow these steps:

  1. Copy this address and paste it into your web browser:
    https://www.livemeeting.com/cc/usergroups/join
  2. Copy and paste the required information:
    Meeting ID: Z7FFBT
    Entry Code: TC%f8)D(2
    Location: https://www.livemeeting.com/cc/usergroups

If you still cannot enter the meeting, contact support

Notice
Microsoft Office Live Meeting can be used to record meetings. By participating in this meeting, you agree that your communications may be monitored or recorded at any time during the meeting.


Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: