“I don’t know why you were whining this morning. The script and its associated content are shown in the following image. Item ParameterizedProperty System.Object Item(System.Object key) Remove Method System.Void Remove(System.Object key) OnDeserialization Method System.Void OnDeserialization(System.Obje… GetObjectData Method System.Void GetObjectData(System.Runtime…. Her command and the associated output are shown here ( gm is an alias for the Get-Member cmdlet).Īdd Method System.Void Add(System.Object key, System…Ĭontains Method bool Contains(System.Object key)ĬontainsKey Method bool ContainsKey(System.Object key)ĬontainsValue Method bool ContainsValue(System.Object value)ĬopyTo Method System.Void CopyTo(array array, int array…Įquals Method bool Equals(System.Object obj) The Scripting Wife typed for a second, and then sat back to examine the results. After you have done that, pipe $hash to the Get-Member cmdlet,” I instructed.
#Powershell regex windows
“OK, open the Windows PowerShell console, and type that same code. What I don’t know is what that means,” she added. $hash = now that was not too bad, was it?” I said encouragingly. “I can do that,” she said while clicking the keyboard. The Scripting Wife’s eyes brightened a bit with recognition. “Create a variable named dollar hash, and set it equal to at sign, left curly bracket, right curly bracket,” I said. In the first column, you can store your friend’s name, and in the second column you can store the phone number.” It is sort of like an Excel spreadsheet with only two columns in it. You can use a hashtable to store pieces of information. “A hash what,” she said with a bit of obvious concern. “The first thing you need to do is to create an empty hashtable.” Why don’t you contemplate starting up the Windows PowerShell ISE so you can write a script to create your phone list,” I said. “That is why you must contemplate it,” she said with wisdom. Besides, I have my shirt on, I cannot even see my navel.” “I’m contemplating the Live Meeting for today, not my navel. “When will you decide? I have got things to do today, and they do not include sitting around here all day watching you sit there and contemplate your naval,” she said. I am still deciding if I want to help you right now.” “Well contemplate this: I would like to query all of the files in the myfriends directory, and pull out a two column list of friend’s names and phone numbers,” she said. “I was just sitting here contemplating my Live Meeting that starts in a couple of hours,” I said. “Uh, well good morning Scripting Wife,” I said in my most subdued cheerful voice.
“I see you trying to sneak off,” she said. I give her my “Who me, I’m innocent” look, whilst attempting to ease my way towards the door. I decide to see if I can make my pot of tea and sneak out of the room without being caught. She seems to be experiencing a bit of frustration. As I enter the kitchen to make a pot of tea, I see the Scripting Wife at her computer. I am debating making a cup of coffee, but I do not feel that it would help…perhaps a nice pot of English Breakfast tea would be worthwhile. Besides that, it is still “oh dark thirty” outside. I am sitting in the dining room, nodding over my laptop-I still have not fully recovered from my all-night flight from Seattle. The questions asked during the presentation are part of what makes the event so much fun. Of course, there are also four more Script Week live meetings, and I encourage you to register for those events.
#Powershell regex registration
Of course, if you have been putting off the registration and the preparation for the games, there is still plenty of time-one can learn an awful lot of Windows PowerShell in six days. The registration for the 2011 Scripting Games is going well, and it is hard to believe that the games kick off in a mere six days. The Script Week Live Meetings have been great fun, and the feedback has been incredible.
Microsoft Scripting Guy, Ed Wilson, is here.
#Powershell regex how to
Summary: The Scripting Wife learns how to use the Windows PowerShell switch command and regular expressions to parse text files.