Richard Siddaway

Explore articles and content from this author

Richard Siddaway

128 articles published

1 min read

PowerShell wins award

PowerShell has won one on InfoWorld"™s Technology of the Year awards for 2013 See http://www.infoworld.com/slideshow/80986/infoworlds-2013-technology-of-the-year-award-winners-210419#slide24 for details

1 min read

Workflow article 4

The next in the series of articles on PowerShell workflows that are appearing on the Scripting Guy blog has been published. The articles in the series that have been published are: http://blogs.technet.com/b/heyscriptingguy/archive/2012/12/26/powershell-workflows-the-basics.aspx http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/02/powershell-workflows-restrictions.aspx http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/09/powershell-workflows-nesting.aspx http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/16/powershell-workflows-job-engine.aspx Look for the next article in one weeks time. Until then Enjoy!

2 min read

Updating Help on PowerShell v3

One of the new features in PowerShell v3 is the capability to update the help files. In fact you have to do this because PowerShell v3 doesn"™t ship with any help files. Since Windows 8 RTM"™d there have been a succession of new help files released. I discovered one of my netbooks didn"™t have the latest version of the help files installed. So I needed to update them. This got me thinking that it would be better if the machine did this for me.

10 min read

Select-string "“ keeping in context

Today"™s question involves using the Context parameter: *It’s probably just me, but I’ve never gotten the switch ‘-context 5 *or -context 2, 7′ to work predictably – where 5 lines before and after or 2 before and 7 after will come out – have you? Let"™s start by looking at the default behaviour of select-string using the search pattern you"™ve seen previously: PS> Select-String -Path c:\test*.txt -Pattern “\A\w{5}ABCD” C:\test\fixedcol.txt:1:12345ABCD123451234512345 C:\test\fixedcol.txt:3:12345ABCD123451234512345

2 min read

Select-String "“ finding the first and last matches

Today’s question concerns finding the first and last matches in a file Sometimes, I need to make two passes at seeking content in this file, once for the first occurrence; and a second grep for obtaining the last occurrence of a phrase. After the second pass, I figure placing the values into an array is the best way, then need to combine first and last values onto one output line {somewhere else}.

1 min read

Workflow article 3

The next in the series of articles on PowerShell workflows that are appearing on the Scripting Guy blog has been published. The articles in the series that have been published are: http://blogs.technet.com/b/heyscriptingguy/archive/2012/12/26/powershell-workflows-the-basics.aspx http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/02/powershell-workflows-restrictions.aspx http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/09/powershell-workflows-nesting.aspx Look for the next article in one weeks time. Until then Enjoy!

1 min read

Select-String"“information on matching files

Following on from yesterday"™s post this is the second question: Since I’m recursively searching thru files to find matching phrases, how can I obtain other directory service information about the matching files file(s) – this is more of a methodology technique question because I realize there are multiple ways of achieving this? You could do something like this foreach ($find in Select-String -Path c:\test*.txt -Pattern “\A\w{5}ABCD” -List){ Get-ChildItem -Path $find.Path

2 min read

Select-String scenarios "“ fixed columns

I had some questions come in after mu recent post regarding select-string. I"™ll answer them as a series of posts. First off: I’m recursively searching thru many files, and want to pull out specific data in ‘fixed column’ positions from the line(s) that match the phrase I’m seeking, i.e. position 10 thru 15 of the line or position 6 thru the end of the line (which might be unknown). What is your preferred method for handling this situation?

1 min read

Select-String confusion

I have seen a lot of confusion recently over the use of Select-String. One mis-conception is that you need to use Get-Content to pipe the file contents into Select-String. Not so. Select-String will read the file for you. If you just want to scan the files in a single folder to find a specific string then Select-String can do the work for you Select-String -Path C:\Test*.txt -Pattern “trial” ““SimpleMatch If you need to work through a folder structure add get-ChildItem to the pipeline

1 min read

Number of processors in a box

WMI enables you find the number of processors in your system: PS> Get-WmiObject -Class Win32_ComputerSystem | fl Number* NumberOfLogicalProcessors : 2 NumberOfProcessors : 1 This works fine for Windows Vista/Windows 2008 and above. Earlier versions of Windows mis-report the number of processors ““ it counts the number of logical processors reports it as the number of physical processors. Win32_Processor has the same problem on Windows 2003 and below. There is a hotfix available from http://support.