Posts

Monitoring rotating text files in real time with Powershell

So I needed a way to monitor some log files in a folder where a new log file gets created when the current one gets too large. All I'm interested in is checking the latest one for certain strings and then alerting if they occur. Powershell to the rescue: #folder to be watched $folder = 'C:\Temp\logger' #file types to be watched for $filter = '*.log' # <-- set this according to your requirements #strings to find in log $matchstring="My matching string" #variable to hold background powershell job $catjob #start a cat task as background process Function StartCat ($filepath) { #stop job is already monitoring a file if ($Global:catjob -ne $null) { stop-job -job $catjob remove-job -job $catjob } $scriptblock = { param ($file, $matchstring) cat $file -wait | ?{$_ -match $matchstring} } #start new job when file changed $Global:catjob = sta...

Wildcard Subdomains in Windows DNS

On a test web server you may have the need to host multiple websites under several subdomains: site1.server.domain.local site2.server.domain.local site3.server.domain.local Setting up the host headers is straightforward, but a bit of work is required in Windows DNS to get the subdomains working correctly. Launch DNS console Expand Forward Lookup Zones Right click on your domain and click "New Domain" Enter the name of your server (if that's what you're using as the top level of the sub domain) Right click the new domain and click "New Host (A or AAAA)" Enter "*" (without the quotes) for the name and then the IP address of your server Click OK On the server in a raised cmd prompt:  ipconfig /flushdns ipconfig /registerdns All done and your your subdomains will be resolved.

Cleaning up Sharepoint 2013 backups

Sharepoint is pretty horrible when it comes to backups, but presuming that you're doing Farm backups rather than just your content database, you'll have to deal with them. I do one full backup per week and differentials in between from Task Scheduler. This generates a lot of data that needs cleaning up, so here's a bit of script. Most of this is directly lifted from a script by  Meat Head Nerd  which I changed to look at the full backups rather than just age of backup. This will remove all full and differential backups prior to the number of full backups you want to keep. # Number of full back ups you want to keep $numfullbackups = 1 # Import the Sharepoint backup report xml file $spbrtoc = “c:\temp\spbrtoc.xml” [xml]$sp = gc $spbrtoc # Find the full backups in spbrtoc.xml $fullbackups = $sp.SPBackupRestoreHistory.SPHistoryObject | ? { $_.SPBackupMethod -eq 'Full' } # Get the start time of the last full backup $lastfullstarttime = $fu...

When SCUP 2011 Cleanup Wizard won't clean up...

In SCUP 2011, there's the Software Update Cleanup Wizard which will remove from WSUS any updates that are no longer in SCUP. Only one problem: if the update exists in WSUS, but the content isn't in UpdateServicePackages, the clean up fails as it can't verify the signature of the cab file. As the wizard doesn't care about the content of the file, it's quite easy to fool it. Open SCUP.log and find the error Create a folder in UpdateServicePackages that matches the folder of the missing content. e.g. \\WSUS01\UpdateServicesPackages\7d0f53e4-482e-462d-b81b-127941c32091 Find an existing cab file within the UpdateServicePackages folder and copy it into your new folder Rename the copied cab file to the name of the missing cab in the SCUP folder Run the SCUP Cleanup Wizard again Clean up success! Seems like a bug to me as removing the entry from the WSUS database shouldn't really care if the content exists.

Locking workstations through GPO

Using GPO to lock workstations after a period of inactivity should be standard behaviour in any organisation, but unfortunately the internet is littered with old information about how to do this. So, ignoring anything to do with screensavers, g o to: Computer Configuration\Policies\Windows Settings\Security Settings\Local Policies\Security Options Set Interactive logon: Machine inactivity limit to whatever timeout period you require Amazing how long it took to find this. H/T:  MS Forum  and the guy who answered it  Deploy Happiness

Windows SMTP Service Mailroot Folders

It may be deprecated in Server 2012, but the built in SMTP service is still extremely useful and is likely to be around for some time yet. When used for bulk emails it's handy to be able to process the non-delivery receipts, but the mailroot folders often cause confusion,  particularly badmail. If the from address accepts mails, the SMTP service will send the NDR to that address and won't keep a copy of the NDR. If the from address is not valid or rejects inbound mail (e.g. no-reply@contoso.com) then a copy is stored in badmail along with two other files (possibly not relevant to your post-processing). To keep all NDRs, change the settings in the SMTP service to send the them to an email address. I use undelivered@machine.domainname where machine.domainname is the name showing under domains in the SMTP service's GUI. Doing this stores all the NDRs in the local  drop folder for later processing. Another thing to watch out for is the FQDN field in the Deli...

SCCM 2012 R2 Console and Performance counters

Just had a issue where the SCCM 2012 R2 Console on Win 8.1 (x64) would no longer connect to the site server after installing MDT 2013 on my local machine. AdminUI.log complained about performance counters. Fix: c:\windows>cd syswow64 c:\windows\syswow64>lodctr /R c:\windows\syswow64>winmgmt.exe /RESYNCPERF Uninstall SCCM Console Reinstall SCCM Console All working again H/T  http://support.microsoft.com/kb/2554336?wa=wsignin1.0

Popular posts from this blog

Avoid Microsoft Intune if you use G-Suite and Android

DFS "Waiting for Initial Replication"

Setting Wallpaper for a Remote Desktop Session