October 2008 - Posts

AD Livemeeting

In this post - http://richardsiddaway.spaces.live.com/blog/cns!43CFA46A74CF3E96!1823.entry - I said I would be doing a Live Meeting on Tuesday 25 November on AD and PowerShell.  I'm beginning to put together ideas for the session so if there is anything that you want covered in particular please leave a message on the blog or email me powershell-uk[at]hotmail[dot]co[dot]uk

 

Share this post :

 

Technorati Tags: ,

PowerShell and WebServices

The slides from Jeffrey Snover's session at PDC have been posted - http://blogs.msdn.com/powershell/archive/2008/10/31/es24-using-powershell-to-create-manageable-web-services.aspx#comments

As well as the stuff on web services there is a look at new functionality for PowerShell v2

 

Share this post :

 

Technorati Tags:

Posted by Richard Siddaway's Blog
Filed under:

Podcast

I recently did an interview with Jonathan for his podcast series.  If you would like to here my views on life, the universe and PowerShell (not necessarily in that order) you can find it at http://get-scripting.blogspot.com/2008/10/get-scripting-podcast-episode-3-richard.html

 

Don't forget to stop by the ATE PowerShell booth next week at TechEd.

 

Share this post :

 

Technorati Tags:

Posted by Richard Siddaway's Blog
Filed under:

PowerShell future

Have a look at this post -

http://blogs.msdn.com/powershell/archive/2008/10/29/574-reasons-why-we-are-so-proud-and-optimistic-about-w7-and-ws08r2.aspx

the amount of PowerShell functionality that is on the way is truly awesome.  If anyone ever doubted Microsoft's commitment to PowerShell this should change their mind. Couple of real stand outs:

  • active directory
  • group policy
  • clusters
  • webadmin - presumably building on what has been done with IIS 7

This comes to a total of 574 cmdlets before we start thinking about providers. This is going to be fun.

 

Share this post :

 

Technorati Tags:

Posted by Richard Siddaway's Blog
Filed under:

W2KSG: Check Spooler Service

Checking the status of a service in PowerShell is very easy.

Listing 13.6 in the scripting guide shows how to check the status of the print service using 8 lines of VBScript. It translates to

Get-Service -Name "Spooler"

It doesn't get any easier.

 

Share this post :

 

Technorati Tags: ,

Posted by Richard Siddaway's Blog
Filed under:

PowerShell by default

The next versions of Windows will have PowerShell installed by default (except server core where its an option) -  http://blogs.msdn.com/powershell/archive/2008/10/28/powershell-will-be-installed-by-default-on-windows-server-08-r2-ws08r2-and-windows-7-w7.aspx

This is going to make remote admin a dream. When you add the new features in PowerShell v2 and the additional Windows functionality based on PowerShell - http://blogs.msdn.com/powershell/archive/2008/10/29/ny-times-delcares-powershell-to-be-30-of-the-value-of-windows-7.aspx

it really is going to be a case of you have to learn PowerShell to do your job.  I'm currently working through the study guide for one of the Exchange 2007 exams and I'm amazed by how much of it is PowerShell based. Takes me back to the SQL Server 6.5 admin exam that was all based on Stored Procedures (yes I know I'm showing my age :-) ).

Command lines rule.

 

Share this post :

 

Technorati Tags:

Posted by Richard Siddaway's Blog
Filed under:

ATE schedule

I've received my time slots for Ask the Experts at TechEd EMEA.  I'll be on the booth

Tuesday 10.00 - 13.00  with Dmitry

Wednesday 15:45 - 19:00

Thursday 13:00 - 18:00

No doubt I'll be around at other times as well.  See you there.

 

Share this post :

 

Technorati Tags: ,

Posted by Richard Siddaway's Blog
Filed under:

Windows 2008 R2

For a preview of some of the Windows 2008 R2 features check out http://www.markwilson.co.uk/blog/2008/10/just-a-few-of-the-new-features-to-expect-in-windows-server-2008-r2.htm

 

Share this post :

 

Technorati Tags:

Greener IT?

One thing I noticed with the laptop and other products I bought at the weekend was that the packaging was all cardboard - easy to recycle.

Is this a response to the Green push??

 

Share this post :

 

Technorati Tags:

Interesting Error

Just come across an interesting error.  I have been experimenting in my virtual machines with some scripts for building and populating distribution groups.  I have 2 DCs in the domain but only had one up and working (the RID Master) and got this error

New-Mailbox : Active Directory operation failed on DC02.Manticore.org. This error is not retriable. Additional information: The directory service has exhausted the pool of relative identifiers.
Active directory response: 00002011: SvcErr: DSID-031A11E5, problem 5003 (WILL_NOT_PERFORM), data 0
At C:\Scripts\Build\newstores.ps1:15 char:13

The DC I was using is the RID Master

Bring up the second DC and ensure replication has happened and everything works again.  One to beware of in virtualised test environments

 

Share this post :

 

Technorati Tags:
Posted by Richard Siddaway's Blog
Filed under:

RANT WARNING

Just bought a new laptop for my son.  Good machine from a well known manufacturer at a very good price.  All great but for the sheer amount of JUNK I have had to clear off the machine to make it anything like usable.

The worst is the so called assistant that claims it can manage my wireless connections for me.  It couldn't manage its way out of a paper bag.  I had to uninstall it to get the wireless working.

I HATE JUNK UTILITIES.

Please make these junk utilities optional - let me set up the machine the way I want and stop filling them up with junk.

 

Share this post :

 

Technorati Tags: ,

Posted by Richard Siddaway's Blog
Filed under:

W2KSG: Asynchronous log access

Script Center Home > Microsoft Windows 2000 Scripting Guide > Scripting Solutions for System Administration > Logs > Managing Logs > Querying Event Logs Asynchronously Retrieving Event Log Statistics

Listing 12.11contains a script to asynchronously access the event logs. Rather than follow the WMI methods we can use the background jobs functionality in PowerShell version 2

Start-PSJob -Name job1 -Command "Get-EventLog -LogName application"

Get-PSJob

Receive-PSJob -Name job1 -Keep

Get-PSJob -Name job1 | Remove-PSJob

We create the job using Start-PSJob.  Give it a name and the command we want to run.  Get-PSJob can be used to view the status of jobs.  Check the state for completed jobs.

Receive-PSJob pulls the data out of the job. Using the -keep parameter leaves the data available to be accessed again otherwise it is removed.

The job can be removed using Remove-PSJob as shown. 

 

Share this post :

 

Posted by Richard Siddaway's Blog
Filed under:

SQL Server PowerShell provider

I have been looking at PowerShell in SQL Server again recently as I'm working on chapters involving PowerShell and SQL Server for a couple of books. I had had a vague understanding that the PowerShell provider could access remote machines but had not really followed up on it. PowerShell is getting to be such as big topic considering the number of products it is built into.

When you open up the SQL Server mini-shell and perform

cd sqlserver:\sql

ls

to step into the database engine and display the contents all you will see is  the current machine.  You can access remote machines by typing

cd server_name

and you will be connected to them.  This also works in the management Studio in that you can right click on a remote registered server and point the provider to that particular server. In effect sqlps has its own remoting system.

Thanks to Dan for pointing that out to me.

 

Share this post :

 

Technorati Tags: ,,

W2KSG: Reading Event Logs

The scripting guide use WMI to read classic event logs.  We have get-eventlog.  Much easier.

# Listing 12.8
Get-EventLog -LogName System

# Listing 12.9
Get-EventLog -LogName System | Where {$_.EventId -eq 7036}

Listing 12.10
Get-EventLog -LogName System | Where {$_.Timewritten -gt ((Get-Date).Adddays(-2))}

Listing 12.8 shows how to read a specific log.  There could be a lot of data there!!  We can restrict the data by eventid (Listing 12.9) or date (Listing 12.10)

 

Share this post :

 

Technorati Tags: ,

Posted by Richard Siddaway's Blog
Filed under:

TechNet event scripts

The scripts from my demos at the PowerShell event on Tuesday are available from here

http://cid-43cfa46a74cf3e96.skydrive.live.com/browse.aspx/TechNet%20%20Event%20October%202008

 

Share this post :

 

Technorati Tags: ,,,
Posted by Richard Siddaway's Blog
Filed under:

Auditing with WMI

If you have been following the series of posts I've been doing regarding the use of WMI to dig into a machine's configuration you will have realised that you could string them together to produce a script that audits the machine and produces a file recording the configuration information. 

Alan, of the UK PowerShell User Group, has done just that - and he has taken it a step further to produce the output as an html file - very nice display.  I recommend having a look at what he's done with this.   http://teckinfo.blogspot.com/2008/10/powershell-audit-script_15.html

Enjoy.

 

Share this post :

 

Technorati Tags: ,,

PowerShell & AD Live Meeting

Tuesday 25 November 2008 -- 7pm-8pm GMT

This Live Meeting will cover:

- How to use PowerShell to work with Active Directory

    - Writing scripts

    - Using the AD cmdlets

- It will mainly cover working with OUs, Users and groups.

- If time permits there will be quick coverage of sites, site-links and subnets and the new features in Windows 2008 AD

Note that audio is only available through your computer speakers\head phones

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/mvp/join
  2. Copy and paste the required information:
    Meeting ID: PMHBJ2
    Entry Code: 5b^W@Mk=z
    Location: https://www.livemeeting.com/cc/mvp

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.

 

Share this post :

 

W2KSG: Unique file names

Having seen how to back up our event logs we will need to do this periodically so we need to create unique file names for the backups. The obvious candidate is to base it on the date.

Listing 12.7

$date = Get-Date
Get-WmiObject -Class Win32_NTEventLogFile | Where {$_.NumberofRecords -gt 5} | Foreach {
    $file = "c:\test\" + $_.LogFileName + "_{0}_{1}_{2}.evt" -f $date.Year, $date.Month, $date.Day
    $_.BackupEventLog($file)
    $_.ClearEventLog()
}

This adapts the previous script by getting the date. We then push the year, month and day into the string for the file name as shown.  That -f operator pops up in a number of very useful places.

The backup and clearing occur as previously. In this case we are using number of records rather than size. You could use both!

 

Share this post :

 

Technorati Tags: ,,

W2KSG: Triggered Event Log backups

We have seen how to backup and clear the event log.  What about checking all of the event logs and doing a backup and clear if they have reached a certain size

Listing 12.6

Get-WmiObject -Class Win32_NTEventLogFile | Where {$_.FileSize -gt 10MB} | Foreach {
    $file = "c:\test\" + $_.LogFileName + ".evt"
    $_.BackupEventLog($file)
    $_.ClearEventLog()
}

Use get-wmiobject to get the event log information. Check the file size. I love been able to just put 10MB as the comparison it just makes life so much easier.  Any log that comes through we can then perform a backup and clear the event log as before.

The comparison could be on NumberofRecords instead of file size if you want to back up after a certain amount of activity.

 

Share this post :

 

Technorati Tags: ,,

W2KSG: Backup Event Log

We have see how to modify event log properties - lets look at backing them up and clearing out the entries. Preferably in that order.

Listing 12.5

$log = Get-WmiObject -Class Win32_NTEventLogFile -Filter  "LogFileName = 'Application'"
$ret = $log.BackupEventLog("c:\test\applog.evt")
if ($ret.returnvalue -eq 0){$log.ClearEventLog()}
else {Write-Host "could not back up log file"}

Start by getting the event log via WMI as we did before.

We can then backup up the event log to a file.  The return value equals zero if everything works. Any other value is an error. We can check the return value and if it is then we clear the log otherwise we get an error message.

 

Share this post :

 

Technorati Tags: ,,

More Posts Next page »