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 […]
Archive for October, 2008
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 […]
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 […]
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 […]
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
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 […]
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 […]
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\" […]
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 […]
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 […]
Categories
- .NET
- Active Directory
- Architecture
- Azure
- Bash
- BITS
- Books
- CDXML
- CIM
- Cloud
- COM
- Containers
- Deep Dive
- Desired State Configuration
- DevOps
- DHCP
- DNS
- DSC
- European Summit
- Events
- Exchange
- File System
- Firewall
- General
- General IT Matters
- Hyper-V
- IIS
- Infrastructure
- IT Community
- IT Security
- Learning PowerShell
- Linux
- Math
- Microsoft
- Modules
- Nano Server
- Networking
- Office 2010
- Office 2013
- Open Source
- Opinion
- Outlook
- Philosophy
- PowerShell
- PowerShell 7
- PowerShell and .NET
- PowerShell and Active Directory
- PowerShell and CIM
- PowerShell and Exchange 2007
- PowerShell and IIS
- PowerShell and SQL Server
- PowerShell and WMI
- PowerShell Basics
- PowerShell original
- PowerShell Summit
- PowerShell User Group
- PowerShell User Group 2
- PowerShell v2
- PowerShell V3
- PowerShell v4
- PowerShell v5
- PowerShell v6
- PowerShell.org
- PowerShellGet
- PowerShellV2
- PSAM
- Rant
- Registry
- Scripting
- Scripting Games
- Scripting Games 2104
- Security
- SQL Server
- Storage
- Strings
- Summit
- Technology
- Uncategorized
- Virtualization
- Windows 10
- Windows 2012 R2
- Windows 7
- Windows 8
- Windows 8 Server
- Windows 8.1
- Windows Server
- Windows server 1709
- Windows Server 2008
- Windows Server 2008 R2
- Windows Server 2012
- Windows Server 2012 R2
- Windows Server 2016
- Windows Server 2019
- WMFv5
- WPF
- WSUS