Textmuster und reguläre Ausdrücke

Textmuster können recht beschaulich sein. Möchten Sie wissen, ob ein Text ein bestimmtes Stichwort enthält, greifen Sie zum Operator -like. Damit kann man Texte also auf relativ simple Art validieren und den Inhalt von Textdateien filtern:

PS> 'Das Kennwort lautet: streng geheim' -like '*Kennwort*' True PS> Get-Content $env:windir\windowsupdate.log | Where-Object { $_ -like '*Warning:*' } 2010-02-15 09:00:07:346 676 16cc DtaStor WARNING: Attempted to add URL http://download.windowsupdate.com/msdownload/update/software/ftpk/2009/09/ 3127922_efd1b6e88dca0406420a85f24eb9497135f89f0a.cab for file 79G26I3KBAZCCoXyTrlJcTX4nwo= when file has not been previously added to the datastore 2010-02-15 11:47:01:166 676 f58 PT ...

Get Scripting mit Windows PowerShell 2.0 - Der Einsteiger-Workshop now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.