header image

Archive for October, 2008

RANT WARNING

Posted by: | October 26, 2008 | No Comment |

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 […]

under: Rant

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 […]

under: PowerShell original

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 […]

under: PowerShell and SQL Server

W2KSG: Reading Event Logs

Posted by: | October 19, 2008 | No Comment |

The scripting guide use WMI to read classic event logs.  We have get-eventlog.  Much easier. # Listing 12.8Get-EventLog -LogName System # Listing 12.9Get-EventLog -LogName System | Where {$_.EventId -eq 7036} Listing 12.10Get-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 […]

under: PowerShell original

TechNet event scripts

Posted by: | October 18, 2008 | No Comment |

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: PowerShell,event,scripts,demos

under: PowerShell original

Auditing with WMI

Posted by: | October 18, 2008 | No Comment |

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 […]

under: PowerShell User Group

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 […]

under: PowerShell User Group

W2KSG: Unique file names

Posted by: | October 16, 2008 | No Comment |

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-DateGet-WmiObject -Class Win32_NTEventLogFile | Where {$_.NumberofRecords -gt 5} | Foreach {    $file = "c:\test\" […]

under: PowerShell and WMI

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 […]

under: PowerShell and WMI

W2KSG: Backup Event Log

Posted by: | October 14, 2008 | No Comment |

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 […]

under: PowerShell and WMI

« Newer Posts - Older Posts »

Categories