PowerShell for Windows Admins


December 29, 2010  1:35 PM

PowerShell UK User Group January 2011



Posted by: Richard Siddaway
PowerShell v2, User Group

Please blog, tweet and communicate to other people interested in PowerShell


Presenter is Ed Wilson – Microsoft Scripting Guy

About Ed Wilson:

Ed Wilson, MCSE, MSCBA, MCT  is the Microsoft Scripting Guy.

As such, he writes the popular Hey Scripting Guy blog for Microsoft,

speaks at conferences such as TechEd and TechReady.

He is very active in the community and has spoken to numerous user groups

around the world via Live Meeting and in person.

Ed has written numerous books about VBScript, WMI, and Windows PowerShell scripting

and his latest release is Windows PowerShell 2.0 Best Practices.

In addition he wrote all the scripts for the Windows Vista,

Windows Server 2008 and Windows 7 Resource kits.

Ed lives in York, South Carolina and Ed has been with Microsoft since 2001.

Prior to becoming the writer of the Hey Scripting Guy blog Ed taught

scripting workshops worldwide to Microsoft Premier customers.

 

When: Tuesday, Jan 11, 2011 7:30 PM (GMT)


Where: Live Meeting

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

Learn Windows PowerShell best practices as they apply to each stage of the script development lifecycle. See the differences between working interactively from the Windows PowerShell prompt, writing an inline script, adding basic function, advanced functions and finally the implementation of Windows PowerShell Modules. What is a local best practice for Windows PowerShell development is not the same as a global best practice, and this talk covers those differences.

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: PPS9QQ
    Entry Code: M5<|wdK;8
    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.

December 6, 2010  1:25 PM

UK PowerShell User Group



Posted by: Richard Siddaway
User Group

Due to family circumstances I won’t be able to organise any events this month.  Normal service will resume in January 2011


November 24, 2010  1:58 PM

January 2011 PowerShell User Group Meeting



Posted by: Richard Siddaway
PowerShell v2, User Group

Save the date -  11 January 2011  7.30 GMT

 

UK PowerShell User group presents a Live Meeting with Ed Wilson – THE Scripting Guy.

Ed will be talking about: 

Windows PowerShell Best Practices

Learn Windows PowerShell best practices as they apply to each stage of the script development lifecycle. See the differences between working interactively from the Windows PowerShell prompt, writing an inline script, adding basic function, advanced functions and finally the implementation of Windows PowerShell Modules. What is a local best practice for Windows PowerShell development is not the same as a global best practice, and this talk covers those differences.

About Ed Wilson:

Ed Wilson, MCSE, MSCBA, MCT  is the Microsoft Scripting Guy. As such, he writes the popular Hey Scripting Guy blog for Microsoft, speaks at conferences such as TechEd and TechReady. He is very active in the community and has spoken to numerous user groups around the world via Live Meeting and in person. Ed has written numerous books about VBScript, WMI, and Windows PowerShell scripting and his latest release is Windows PowerShell 2.0 Best Practices. In addition he wrote all the scripts for the Windows Vista, Windows Server 2008 and Windows 7 Resource kits. Ed lives in York, South Carolina and Ed has been with Microsoft since 2001. Prior to becoming the writer of the Hey Scripting Guy blog Ed taught scripting workshops worldwide to Microsoft Premier customers.

 

Live Meeting invites to follow


November 20, 2010  8:29 AM

PAM 0.4



Posted by: Richard Siddaway
PowerShell v2, PSAM, WMI

PowerShell Admin Modules 0.4 is now available.  This adds a PAMSysInfo module to the download that includes the following functions:

Get-BIOSInfo
Get-Bus
Get-CDROM
Get-ComputerSystem
Get-CPU
Get-MemIrq
Get-OSInfo
Get-PageFile
Get-System
Get-TimeZone

Get-SystemInfo is a top level function that calls the others for a full system information dump.  All functions take a computer name as their only parameter.

PAMSysInfo isn’t complete but there is enough to start making it useful

Download from http://psam.codeplex.com/

Enjoy


November 20, 2010  6:59 AM

Memory, IRQ and devices



Posted by: Richard Siddaway
Hardware, PowerShell v2

One of our most valuable system resources is memory. Back in the day we also used to worry about IRQs as we only had 16 but modern Windows gets round this for us.

If you want to know what memory is being used by which device then try this.  We also get IRQ as a bonus

$source = @"
public class sysirqram  {
public string Memory { get; set;}
public string Device { get; set;}
public string Status { get; set;}
public long IRQ { get; set;}
}
"@
Add-Type $source -Language CSharpVersion3

$data = @()
Get-WmiObject Win32_DeviceMemoryAddress | foreach {

$name = $_.Name

$query = "ASSOCIATORS OF `
{Win32_DeviceMemoryAddress.StartingAddress=’$($_.StartingAddress)’} `
WHERE RESULTCLASS = Win32_PnPEntity"
Get-WmiObject -Query $query | foreach {

  $qirq = "ASSOCIATORS OF {Win32_PnPEntity.DeviceID=’$($_.PNPDeviceID)’} `
  WHERE RESULTCLASS = Win32_IRQResource"
  $irqs  = Get-WmiObject -Query $qirq | select IRQNumber -Unique
 
  $myobject = New-Object -TypeName sysirqram -Property @{
   Memory= $name;
   Device = $_.Name;
   Status = $_.Status;
   IRQ = $irqs.IRQNumber
  } 
  $data += $myobject
}
}
$data | Format-Table -AutoSize

Define a new class and create it using Add-Type.  We can then start with the Win32_Devicememory class to discover what memory is being used. Thsi can be associated with the Win32_PNPEntity class to get the device which we then associate with Win32_IRQResource to get the IRQ.

Not the simplest of WMI scripts but its logical when you pick it apart


November 18, 2010  1:25 PM

Joining a domain



Posted by: Richard Siddaway
PowerShell v2, Windows 2008 R2

I was creating a new virtual machine and decided to test the JoinDomainOrWorkgroup method of the Win32_ComputerSystem class

The syntax is relatively straight forward

$comp = Get-WmiObject Win32_ComputerSystem
$password = "Gu3ssWh4t"
$user = "Manticore\Richard"
$domain = "Manticore"
$comp.JoinDomainOrWorkgroup($domain, $password, $user, $null, 3)

It kept failing with a 1316 return code.  Couldn’t find a reference to that so eventually tried using Add-Computer.  That told me the computer account already existed.  OOOPS. Got the name wrong.  One quick rename later and we’re in business


November 14, 2010  2:07 PM

PAM 0.3



Posted by: Richard Siddaway
PowerShell v2, PSAM

I’ve added another module to the PSAM project on codeplex.

Version 0.3 now has:

PAMShares – for working with shares
PAMMath – for working with binary and hex
PAMEnv – for working with environmental variables

The modules can be downloaded from http://psam.codeplex.com/

Enjoy


November 14, 2010  4:46 AM

PowerShell and WMI book



Posted by: Richard Siddaway
Books, PowerShell v2, WMI

A few months ago I started work on a follow up to PowerShell in Practice – http://www.manning.com/siddaway/ .

This book will also be published by Manning. It covers PowerShell and WMI.  These two powerful technologies work well together to give a superb environment for managing your systems. WMI has had a bit of  a bad reputation over the years but PowerShell really does make it easy to work with. 

The first three chapters are available no through the Manning Early Access Program [MEAP] from http://www.manning.com/siddaway2/

Chapters 4 and 5 are in the pipeline and I’m currently working on chapter 6.

Please leave any comments on the author forum or here

Enjoy.


November 12, 2010  1:46 PM

PowerShell in Practice goes mobile



Posted by: Richard Siddaway
Books, PowerShell v2

PowerShell in Practice is now available in mobi and epub formats for use on Kindle, iPhone, Sony Reader etc etc

If you have a copy of the book you should be getting emailed about the availability of these new formats.  Otherwise check out http://www.manning.com/catalog/mobile/


November 8, 2010  4:38 PM

Cache memory



Posted by: Richard Siddaway
Hardware

 

Processors have cache memory as we saw when we looked at Win32_Processor. We can find more details about the cache memory using the Win32_CacheMemory class

001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
$assoc = DATA {ConvertFrom-StringData -StringData @’
1 = Other
2 = Unknown
3 = Direct Mapped
4 = 2-way Set-Associative
5 = 4-way Set-Associative
6 = Fully Associative
7 = 8-way Set-Associative
8 = 16-way Set-Associative
‘@
} 

$ct = DATA {ConvertFrom-StringData -StringData @’
1 = Other
2 = Unknown
3 = Instruction
4 = Data
5 = Unified
‘@
}

$wp = DATA {ConvertFrom-StringData -StringData @’
1 = Other
2 = Unknown
3 = Write Back
4 = Write Through
5 = Varies with Address
6 = Determination Per I/O
‘@
}

$sram = DATA {ConvertFrom-StringData -StringData @’
0 = Other
1 = Unknown
2 = Non-Burst
3 = Burst
4 = Pipeline Burst
5 = Synchronous
6 = Asynchronous
‘@
}

function ssram {
 
param ($supsram
)
 
$ret = ""
 $supsram | foreach
{
 
$ret += $sram["$($_)"] + ", "
 
 }
 
$ret.TrimEnd(", "
)
} 

Get-WmiObject -Class Win32_CacheMemory | 
foreach
 {
 
$_ | select DeviceID, Purpose,
 
 @{Name
="Associativity"; Expression={$assoc["$($_.Associativity)"]}},
  BlockSize,
 @{Name="Cache Type"; Expression={$ct["$($_.CacheType)"]}},
 
 
InstalledSize, NumberOfBlocks, MaxCacheSize,
 @{Name="Current SRAM"; Expression={$sram["$($_.CurrentSRAM)"]}},
 
 @{Name
="Supported SRAM"; Expression={ssram $_.SupportedSRAM}},
 
  @{Name
="Write Policy"; Expression={$wp["$($_.WritePolicy)"]}}
}

 

 

 

 

 

 

Most of this should be familiar by now.  We create some hash tables as lookups. Then we use Win32_cachememory.  The replacement of integer codes by their meaning looked up from the hash table is straight forward. The trick in this is decoding the SupportedSRAM property. its an array of integers so I had to write a function to work through the array members, decode them and add the results to a string that we can then display.


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: