For those of you that have been at PowerShell Summits over the last few years you’ll have heard Jeffrey Snover state that he wanted to take PowerShell to other platforms.
Now its happened
Jeffrey has announced that an ALPHA release of PowerShell is now available for Linux and Mac. Currently available for Ubuntu, Centos, Red Hat and Mac OS X with more to come
At the beginning of July, we welcomed our 3rd son into the world. As days past my wife and I would say, “wow, he’s 11 days old. Can you believe it?!”. I’m sure parents out there are relating to this! This gave me an idea for a fun script that would get your age in years, months and days, tell you how many days until your birthday and your star sign. I wanted date of birth passed to the function as ‘dd/MM/yy’. To keep to this format, I’m using the ‘ValidatePattern’ Advanced Parameter with a Regular Expression (Regex). The regular expression, “^(0[1-9]|[12]\d|3[01])/(0[1-9]|1[0-2])/(\d{2})$”, will only allow a date in the format of 01/01/16, for example. Briefly, here is regex syntax I used in some of the expression: ^ Start of string ( .. ) Capturing group (0[1-9] Match two digits that make up the day. This accepts numbers from 01 to 09 | Acts like a Boolean OR. /d match any digital character [12] match any character in the set / used to divide the date numbers {2} Exactly two times $ End of string Now that my function parameter variable $Bday has a date, its passed to get-date to be converted from a string to a date. The date in variable $cDate will look like this, ‘01 January 2016 00:00:00’. The next line in the code will use todays date and subtract the date passed in $cDate variable. The $diff variable will contain the following data which we will use to get our age in years, months and days: Days : 212 Hours : 12 Minutes : 40 Seconds : 20 Milliseconds : 533 Ticks : 183624205335135 TotalDays : 212.528015434184 TotalHours : 5100.67237042042 TotalMinutes : 306040.342225225 TotalSeconds : 18362420.5335135 TotalMilliseconds : 18362420533.5135 I’ve contained this first part in our Begin block. The Process block does the main code. Now I need to get my age in Years, Months and Days. This is where the [math] data type is used. I’m using the ‘Truncate’ property as I don’t want to do anything fancy like round up my numbers. Adding the .typename of Days to my $diff variable and dividing by $daysInYear variable I can get my age in years. The next two, months and days required a tweak to the algorithm. I ended up using a maths term called a ‘Mod’. Now I’m not talking about youth culture and style in the sixties (Mods and rockers anyone ??), but the Modulus Math Operator. Basically the Modulus Operator returns the remainder when the first number is divided by the second. So for example: 1 mod 3 = 1 (or 1 % 3 = 1) 2 mod 3 = 2 3 mod 3 = 0 4 mod 3 = 1 The operator sign used is % for Modulus. Not to be confused for the alias of foreach in PowerShell. For days in a month, I used the average of 30. I thought it would be fun to add the star sign as well. I was after something that could tell me, “is this date in this date range?”. One of the properties of ‘get-date’ is DayOfYear. Finding if a number is in a range is pretty straight forward, For example:
I’m collecting a list of known problems in DSC v5 _that have been solved. _Like the infamous “MI RESULT 12” error that could happen if you upgraded from prerelease v5 to production preview. I’m going to document these in “The DSC Book,” including in its free sample version, to help preserve these things in one place. Again - these need to be solved problems. Just drop as much description as you can into a comment here, and feel free to link to the fix, or to a discussion thread on the problem. And please - pass this around. If you’ve never had a chance to contribute to “the community” before, now’s a great time. Even if it’s a problem that you know doesn’t exist in the current v5 release, let’s please just document its former existence. Thanks!
The PowerShell and DevOps Global Summit is the number one conference where PowerShell enthusiasts gather and learn from each other in fast-paced, knowledge packed presentations. PowerShell, and DevOps, experts from all over the world including MVP’s, community leaders and PowerShell team members, will once again join together for a few days in Bellevue, WA. to discuss and learn about maximizing PowerShell in the workplace.
It’s also the place to explore and further your knowledge of DevOps principles and practices in a Windows environment. It’s a place to make new connections, learn new techniques, and offer something to your peers and colleagues. If you want to share your PowerShell or DevOps expertise, then this is your official call to submit presentations for selection!
“To be or not to be”. Without getting into a debate over whether Shakespeare was musing about being a logician, suffice to say that in writing prose, the rules of when and how to use quotation marks are relatively clear. In PowerShell, not so much. Sure, there is an about_Quoting_Rules documentation page, and that is a good place to start, but that barely covers half the topic. It assumes you need quotes and then helps you appreciate some of the factors to consider when choosing single quotes or double quotes. But do you need quotes? Remember PowerShell is a shell/command language so “obviously” you can do things like this:
Join the Mississippi PowerShell User Group virtually on Tuesday, July 12th 2016 at 8:30pm Central Time when Mike Fal will be presenting “Exploring SQLPS, the SQL Server PowerShell Module”. A big hurdle for using PowerShell and SQL Server together is the SQLPS module. Both old and new users of PowerShell don’t completely understand its capabilities. In this session, we’ll talk about the cmdlets you may not know about, tricks to save time using the provider, and even a few gotchas on how the provider works that can save you some time and energy. When we’re finished, you will have a deeper understanding of how you can use SQL Server and PowerShell together. Visit the Mississippi PowerShell User Group website to learn more about Mike and to find out more details about this month’s meeting. The Mississippi PowerShell User Group Meetings are held online (via Skype for Business) on the second Tuesday of each month at 8:30pm Central Time and are free to attend. The system requirements to attend these online meetings can be found on the MSPSUG website under the “Attendee Info” section. Register via EventBrite to receive the URL for this meeting. Note: It is not necessary to live in Mississippi or join our user group to attend our meetings or present a session for our user group. µ
So! If you visit the PowerShell.org events page, you’ll find a bevy of PowerShell-focused events, from local PowerShell user groups to global PowerShell conferences. What you won’t find, yet, is a list of PowerShell related sessions at the many other conferences and user groups you might consider attending. Maybe you’d like to find PowerShell oriented sessions at non-PowerShell user groups and mini conferences like SQL Saturdays, VMUGs, Azure User Groups, Security BSides, DevOpsDays, etc. These are great small events that can build your knowledge, help you meet local folks in a particular field, and often provide provide you with some free food. Beyond these, there are plenty of summits and conferences that have a strong PowerShell track, or even just a handful of awesome PowerShell sessions, that might be worth knowing about. LISA, DerbyCon, MMS, WinOps, TechMentor, and many more. How do you find these events? There isn’t a solid option today, but hopefully we can change that. Before we go further though, why is this even helpful?
As this is my first blog here, here’s a bit about me. I’m a current lead SCCM Admin in the UK, and have found this great enjoyment for PowerShell in the last 18 months. I’ve started my own blog, http://www.get-configmgr-content.co.uk/, to share my passion. The chance to blog on Powershell.org was too exciting not to do! The inspiration for this blog came from a forum post on Powershell.org that I helped contributed on. The question asked was, how to display the name of failed ping, i.e. $computer is offline. There were some great responses, the one I most liked which I slightly amended into a function was:
We’ve been making a ton of improvements at PowerShell.org… if you haven’t visited in a while, it might be worth a stop by. **First, **if you’re hitting any of the links below and getting a 404, the most common culprit seems to be an over-zealous corporate proxy cache. Try clearing it, or doing a Shift+Reload in your browser. Confirm by visiting from a non-proxied network, like at home. Our eBooks page has a bunch of new content, and our books are now available in PDF, MOBI, and EPUB from two providers (LeanPub and GitBook). You can also read books online in HTML. Site members now have an extensive profile that you can complete, and doing so is one step on our short Welcome Aboard! mission that will earn you a new “Welcome!” badge on the site. It’s one of many new achievements you can earn for participating in the community in a variety of ways. And have you seen our new videos? In addition to tons of YouTube videos that include workshops, tutorials, and Summit recordings, we also have started new short-subject, structured learning series - entire courses that even award a certificate of completion when you’re done! But there’s much more we can do to help you connect with community, so we’re taking a quick survey. Here’s some of what we can enable: