A post he hasn't written yet has been deleted.
Best posts made by Martin9700
-
RE: So, working on a little Node.js project...anyone have any experiences to share?
I'm concerned that something is missing from your Network Scan though. This is a cool feature, though!
-
RE: So you need a simple SMTP relay test? You can do it with P0werShell!
Port parameter wasn't introduced until PowerShell 3.0, so you'll need to make sure you're on at a minimum of that before this will work. PowerShell 4.0 is the current version and 5.0 is coming out SOON. So if you're still on 2.0, upgrade now!
-
RE: PowerShell command: Event Time
@g.jacobse said:
0x01d0b26dc6a4a844
That value isn't a .NET date/time value so Get-Date won't be able to process it properly (hence the year 0415). So I tried this: http://superuser.com/questions/398983/how-do-i-decode-the-faulting-application-start-time-in-a-windows-event-log-ent
(get-date "01/01/1601").AddSeconds(0x01d0b26dc6a4a844 / 10E+6)
And got:
Monday, June 29, 2015 1:16:14 PM
Seems much better!
-
RE: Understanding $args in PowerShell
Let me take a stab at explaining an array. It's just a list. When you write your groceries on a piece of paper you have a variable with multiple values on it. You don't write a single item per piece of paper, right? If you did that'd be a regular variable. Instead you put the whole list on one piece of paper, making it an array/list.
Computers are great with lists, but they have some limitations, and they have to be told to do things in a very literal sense. So, grocery list is:
$GroceryList = "beer","wine","whiskey","brandy","vodka","chips"
In PowerShell, the comma's are what tell PowerShell that this is an array. Now, if I ask you what's the 3rd item in the list, you would scan through and count each one, until you got to "whiskey". PowerShell is the same way, but we can jump straight to the third item. Try:
$GroceryList[3]
The brackets with the number tell PowerShell that you want to reference a particular item in the array. The number tells you which item. So we got Whiskey, right? If you tried it, you know we got "brandy". WTF? In programming languages, and this is pretty much universal, arrays always start at zero. So $GrocyerList[0] is beer, $GroceryList[1] is wine, and last $GroceryList[2] is whiskey. So when working with arrays you'd really want to:
$GroceryList[2]
To have PowerShell return the 3rd element. Each item in an array is called an element, by the way. Looking back at Scott's code, what he was doing was creating a For/Next loop, which is a loop using a number as reference.
for ($i = 0; $i -lt $GroceryList.Count; $i ++)
Is some goofy looking stuff, but the first part $i = 0 marks our starting point. $i = 0. The next part is a IF statement, that as long as it's true we'll continue the loop. In PowerShell we have built in properties, and one of those is Count which tells us the number of elements in the array. So as long as our $i variable is less then that count, we'll keep looping in the for loop. The last part $i ++ tells the loop, that when I'm done with the loop add one. The ++ thing is basically shorthand for $i = $i + 1.
Now PowerShell will continue to run the code contained in the scriptblock (all the code between the curly brackets) until our $i variable equals or is greater than the number of elements in our $GroceryList. So the first time through the loop $i = 0, we display that number, and we reference the element in our array that corresponds with zero. Which is beer. Loop ends, $i increments to 1, start again.
Loop displays the number 1, and shows the $GroceryList element that corresponds to that number, which happens to be "wine". Code block ends, $i increments to 2. This is still less the $GroceryList.Count (which is 6, btw) so the loop repeats. Onward until $i get's to 6, at which point it exits the loop and continues on with the script. In this case there is no more script, so it exits the script and drops you back into the shell.
-
More PowerShell Goodness...
If you love reading about improving performance in PowerShell (which admittedly isn't its strong suit) then you'll love these two posts. First one:
http://thesurlyadmin.com/2015/01/26/dynamic-fields-in-objects-what/
sets the stage. I talk about creating an object where the properties can update dynamically based on values in other properties of the object. It's THIS close to class, without the persistence or reusuability. And then with a little playing we discovered how cool this technique could be:
http://thesurlyadmin.com/2015/01/27/dynamic-properties-in-objects-and-performance/
-
Latest Blog Post: Shrink MS SQL Log Files with PowerShell
http://thesurlyadmin.com/2015/01/05/shrink-sql-log-files/
Since it's all about self-promotion, figured I'd put this out there to see what happens. Let me know what you think.
-
PowerShell.org announces it's 2015 Hero's
Couple of SpiceHeads (don't think either are here on Mango) just got recognized as 2015 PowerShell Hero's by PowerShell.org! Come congratulate them
http://community.spiceworks.com/topic/744795-powershell-org-announces-its-powershell-hero-s-for-2015
-
RE: Microsoft Sculpt Ergonomic Keyboard For Business
I use the Sculpt--probably about 3 weeks now--and for the most part it's great. I got the mouse that came with it and I highly recommend against getting it. It's rounded and actually forces you to bend your wrist which is what you shouldn't be doing! Ended up going back to my Logitech and it's fine.
The separate number pad sucks, but it does keep your mouse closer to the keyboard which is also highly recommended. I don't use the number pad as much as I used to but I am finding myself using it more and more as I get used to the setup.
Overall it's a good keyboard and I haven't had any hand pain since going to it, though I had some when I first got it and was adjusting to it.
-
RE: How to website
While not this exact text, this is what drove me to start my own blog. And it's really worked. When "teaching" you are forced to look at a problem from several different angles and make sure you know what you're talking about. Go for it!
-
RE: Favorite PowerShell Commands?
I love using Select-String. Nothing quite as cool as taking a huge log file, parsing out EXACTLY what you want out of it and making a custom object. Version 5 of PowerShell now has the ConvertFrom-String cmdlet that'll make doing this much easier than using RegEx. But where's the challenge?!?!
-
RE: PowerShell
Don't learn PowerShell... do PowerShell.
Pick a week, and force yourself to use PowerShell for all your daily tasks (within reason, don't set NTFS permissions with PowerShell, that sucks). But need to reset a user's password? PowerShell. Find out if they're locked out? PowerShell. That kind of thing.
I rarely open Active Directory Users and Computers (ADUC) anymore. I can do everything faster from the command line.
-
RE: Powershell Line Break at Comma
Should look into using Send-MailMessage for email. It's a lot easier to work with.
-
RE: Understanding $args in PowerShell
@scottalanmiller said:
@chutestrate said:
which script the args or param
Using param to abstract args is going to make learning what an array is less simple.
OK, now I see where you're going with this. I suppose that's an argument, but in my view you should know what an array is and how to manipulate it before you start messing with $Args. Otherwise your picking a tough path to walk. Besides, learning best practices early instead of breaking bad habits later.
-
RE: Community Update & Patch Saturday: March 8, 2014
@steve said:
Metro Tiles This is the one that everyone will notice straight away, on the main page the previously static tiles are now animated and show some of the content from those topic areas.
Hi @steve , gotta just say not a huge fan of the tiles changing. Having the number of threads in there, or an unread number would be great but keep the title on at all times. If you want to have a small scrolling section for "quotes" that's fine, but the title should always be on. It's really for us old guys, because I can't remember my own name if it's not up all the time
-
Feature Request - Unread view
Just a request to put in the queue, I can only imagine how much work this must be!
It'd be really cool if the Unread section, over to the right, instead of showing the last item posted, it would show the last item posted since you last looked! Easier to catch up on the conversation. This one sounds like such an easy request but I realize it's far from it.
Thanks
-
RE: The WordPress on CentOS LEMP Challenge
Only problem I see, is it's not really a one liner. If I'm reading it right (and I may not be) then a semi-colon is a command separator? That means it's really a dozens of lines script that you've just forced into a single line.
-
RE: February 13th (Friday) - MangoLassi Day!
Getting Microsoft and MSP's to come visit once is pretty cool, but there's almost no content here for those people. There's ZERO Enterprise level content from a Microsoft basis. Frankly I get a bit of a anti-Microsoft vibe here. How do you plan on getting these people to do more then a single visit, look at a few posts and never come back?