Category Archives: PowerShell

UK Powershell User Group

Following on from the last great meeting the next UK Powershell User Group has been announced…

The November meeting of the User Group will be on Thursday 20th November

Time
6.30 – 9.30

Location
Memphis Room
Building 3
Microsoft campus
Thames Valley Park
Reading

Agenda

  • Powershell Introduction: Objects and get-member
  • PowerGUI SQL Server Reporting Services powerpack
  • PowerShell in SQL Server 2008

If you want to attend please send an email to powershell-uk@hotmail.co.uk expressing your interest.

Re-posted from http://richardsiddaway.spaces.live.com/Blog/cns!43CFA46A74CF3E96!1806.entry

Using Powershell to make you money

We recently had to get some lists together for the Licensing department as there are virtualisation deals which can be used to reduce the amount of licensing costs for your VM’s.

Im not sure what they are this week but last time I checked you could license all VM’s on one host with 1 Data center license. I think there are also deals for 3 vm’s per Enterprise license or similar ?

So with the following powershell script we were able to integrate the VI toolkit with WMI information to gain the information needed…

connect-viserver MYVISERVER
$vms = Get-VM | select-object Name, Host

$myCol = @()
foreach ($vm in $vms)
{
$MyDetails = “” | select-Object Host, Name, OS
$MyDetails.Host = $vm.Host
$MyDetails.Name = $vm.Name
$OSDetails = Get-WmiObject -class Win32_OperatingSystem -computername $vm.Name
$MyDetails.OS = $OSDetails.Caption
$myCol += $MyDetails
}
$myCol | sort Host

Sample output:

Host : HOST01.TEST.gov.uk
Name : TEST01
OS : Microsoft Windows 2000 Server

Host : HOST01.TEST.gov.uk
Name : TEST03
OS : Microsoft Windows 2000 Server

Host : HOST02.TEST.gov.uk
Name : TEST02
OS : Microsoft Windows 2000 Server

Map your VI using Netmap

At the UK Powershell user group James used Netmap, I was intrigued with this and what it could do, with a few lines to integrate this into the VI toolkit I managed to get a nice map of which VM’s were on each host.

Download Netmap here and try it for yourself….

Connect-VIServer yourserver
$vmhs = Get-VM

$myCol = @()
ForEach ($vmh in $vmhs)
{
$myobj = “” | select-Object source, target
$myobj.source = $vmh.host
$myobj.target = $vmh.Name
$myCol += $myobj
}

$mycol | Export-Csv .\Temp.csv
Import-Csv .\Temp.csv | show-netmap

Im also working on a Visio script which will produce a much more pleasing to the eye report…Watch this space and let me know if you would like to test it for me in its early phases.

WSUS PowerGUI Powerpack

Jonathan Medd has done it again, yet another great PowerPack for PowerGUI, following on from his Exchange 2003 PowerPack he has created a WSUS PowerPack.

This is still a work in progress project but it looks great to me.

WSUS Administrators can now access their servers using Powershell! Get access to information not accessible from the WSUS console.

Take advantage of the PowerGUI reporting actions to increase your ability to report on info direct from WSUS.

The tool could also prove a useful information gathering tool for a consultant going to examine an unfamiliar WSUS installation.


					

PowerScripting Podcast

Ok, I have blogged about this before but am going to again, one of the most valuable resources I have found for learning powershell is podcasts, there are two PowerShell podcasts out there at the moment that I listen to, Get-Scripting by Jonathan Medd and The PowerScripting podcast by Jonathan Walz & Hal Rottenberg.

I started off listening to the latest episodes when I began with Powershell and then it was mentioned to me that the earlier episodes were great for newbies.

I have now been listening to the back catalogue of episodes (Currently they are up to number 42) and have found them a great resource for both learning PowerShell and keeping up to date with all the third party products, news and tips.

Recently they have also started recording the show whilst using ustream which makes the whole experience far more interactive for us the users of powershell.

With recent guests such as ‘The Iron man’ aka Jeff Hicks and ‘Green Arrow’ aka Greg Shields I was left wondering who the presenters could be in there nightly fighting of crime ?!?

The only possible answer I could come up with was Batman and Robin, and I’m sorry Hal you have to be Robin as anyone who has listened to the earlier shows knows that Jonathan started fighting crime far earlier than you !

For anyone who has not yet listened to the shows, please go ahead and download them at the PowerScripting site and learn from the Powershell Guru’s today.

Get-Busy Scripting !

Update: Hal has now become a MVP for his work in Powershell, Nice one Hal ! Also in the recent podcast they confirmed that if they were to be super heroes it would be someone from Heroes, personally I think they better suite Batman and Robin fighting the evil Javascript and Perl bad guys 🙂

(P.S. Any thought’s on both Javascript and Perl are that of my own and not any reference to anything from the podcast)

UK Powershell User Group

I had my first experience of the UK Powershell Users Group last night, based out of the Microsoft Campus in Reading.

First to speak was James O’Neil who took us through the powershell cmd-lets he had written for managing Hyper-V through powershell which can be downloaded here for free, he went into some very detailed WMI tasks he had written to perform this and some tips and tricks using WMI and mapping the connections using Netmap

At times a little over my head but very useful and clearly a man who now knows WMI inside out !

After the masses of Pizza that was available due to people not turning up we then continued with Jonathan Medd (Creator of Get-Scripting blog and great Podcast) took us through his PowerGUI management tools for Exchange 2003.

Very Impressive, thanks to Jonathan’s neat tool you can now integrate Powershell into managing Exchange 2003 and quickly gain stats and perform admin tasks on Exchange, something which Microsoft have only released for Exchange 2007. Jonathan gave a detailed presentation showing off the features of both PowerGui and his tool he had written.

Until know I have always skipped the PowerGui side of things just to use the script editor to edit my scripts, I may even create my own PowerGui power pack including some of the scripts I use on a daily basis.

All in all it was a great meeting and I suggest more people attend, as well as the great presentations there was also the attendance of Richard Siddaway (MVP) and some other Powershell GURU’s who made for great conversation. We also received some freebies and a random draw gave one of the guys a free Powershell book.

The next one is being scheduled for November and I would highly recommend attending if you can.

Checking logs

Ok, so its monday morning, I come in and there are an onslaught of emails (no change there) from some issues over the weekend.

It would seem there was ‘an issue with vmware’ and the virtual machines were restarting left right and center, imediately I think….Network issue.

To find the answer (for which I was correct) I used the following quick bit of code…

Connect-VIServer myviserver
$esx = Get-VMHost myhost
$log = Get-Log -Key “vmkernel” -VMhost $esx
$log.entries > c:\logs.txt

This showed that the service console nic had lost connection to the network, confirmed around 1hr later from our networks team saying the primary core had re-booted itself 🙂

Powershell: Print server details

Scenario: I was performing some maintenance on one of the print servers where I currently work, we needed to take the server down for a period of time.

The help desk wanted to send an email to the users telling them that the users of PrintServer1 would not be able to print during this period.

Would you know which print server your printer is attached to ? Would the users ?

Answer: With the following powershell one liner we were able to tell the users which printers would be unavailable for that period of time:

“PrintServer1″ | ForEach-Object{get-wmiobject –computername $_ Win32_Printer | select-object Caption, Location} | Export-Csv “C:\PrintServer1.csv“