There are a few articles already out on the Internet, but every time I need them, it takes me forever to find them (have you heard of bookmarks?). I decided to write my own post so I know I’ll always be able to find it.
I’ve just copied and pasted about 100 lines of PowerShell code to a script I’m writing, but the indentation is way too far in for this. I’d love to just select all of it and use a key combo like indenting.
The solution is easy, just use this key combo
Shift + Tab
That’s it! Why can I never remember this? Now I don’t have to. I just need to remember I wrote this article.
On April 8th 2016, I got the below e-mail from Microsoft.
|The amount of free storage is changing.|
|Having trouble viewing this message? Click here.|
If you’re not a OneDrive user, this might not affect you directly, but you should understand what is happening here.
What is Microsoft doing?
Well, in a nutshell, they’re taking storage space they previously provided to their users free of charge away.
Can they do this?
Of course they can. It’s not your storage space. You technically owned nothing when you signed up for your OneDrive account.
I’m safe because I’m not using OneDrive, I’m using (Enter any other free storage cloud service) right?
The important thing to understand with all of these free cloud based storage services is that you don’t own anything (except your content) related to the service. You do not own the quota or storage space allocated you. You are simply allowed to use it based on the current terms written by the provider. All of these services will leave open the option to change the amount of free storage they give you.
I should just accept this and move on then?
Yes and no. When I first got this message I was really mad at Microsoft. I’ve had a Onedrive (formerly Skydrive) account for a really long time. I haven’t had the need to buy any storage space for my account because of these extras they were giving me. I have paid for storage for my other Onedrive account that my wife and I share for our family photos etc. My own personal account was sufficient at the free level.
Now, I’m not sure what I’m going to do. I understand what they’re doing, to a degree, but I still believe what Microsoft is doing is really nasty. It feels much like a bait and switch scheme. Why? Well, if you are offered for free, a considerably larger amount of storage space over all the other services, you’re going to have a higher likelihood of switching to this service. Then, once you’ve committed, they take away most of what brought you over. You’re stuck with either paying up, or finding a different service.
I get any of these services could do this. I’m not a lawyer and I doubt they did anything illegal, they’ve got a lot more people working on this stuff to know better. It just seems really shady to take the storage away after you’ve been using it long enough to get yourself stuck in a corner. What are your thoughts? Do you agree? Disagree? Why?
I say this, COME ON MICROSOFT!!! You were really starting to grow on people again, all to go and do this. Shame on you! You’re taking 3 steps back again.
If you’re writing PowerShell scripts the right way, you’re testing your scripts against a Test, or DEV environment prior to deploying those scripts to your Production environment (You ARE testing your scripts right?). If you’re using source control for your scripts (You ARE using source control for your scripts right?) then you’re likely using a DEV branch for your in progress script and then when all is ready you can Merge that into MAIN or whatever you call your production branch.
NOTE: If you aren’t using source control, branching & merging, and testing, you’ve probably got bigger problems than your PowerShell profile.
If you are able to remotely run your code against your servers or if you’re like me and you’re managing Office 365, you’re running your test scripts and your production scripts on the same workstation.
Some of the common repeatable steps I have to take to differentiate my DEV and PROD instance are to change my directory I’m running my scripts from and since I write a lot of Modules, I need to ensure I’m using the correct Modules.
Out of the box, you’re going to have to manually change your directory and go in and add a temporary module directory depending on where your DEV and PROD modules are stored. I can write a script to do this and that’s what I’ve done, but instead of calling that script manually, why not incorporate it into your profile?
Below is a simple profile I’ve created for my workstation that allows me to determine what environment I’m working in when I run PowerShell. Now, I do nothing different when I open my Windows PowerShell. When it executes it runs the $profile and my script executes prompting me to enter “DEV” or “PROD” based on what I’m working on at the time.
Here’s the script you will copy and paste into your $profile file on your workstation. See below for the instructions.
What is this script doing?
There are three specific tasks this script is doing.
- Add Temporary Module Path (based on Parameter entry)
- Sets Current Directory (based on Parameter entry)
- Changes Prompt text and color (based on Parameter entry
Follow these steps to include the script above into your Windows PowerShell Profile. Note there are pieces you need to modify in the script above that are wrapped in <>’s. You’ll need to change the paths to represent your own locations.
- Open Windows PowerShell
- Verify you have a $profile created. Click for instructions and information about PowerShell Profiles
- Edit your profile by entering the following command: notepad $profile
- Copy the code above (make sure you’ve changed paths to represent your paths) and paste the code into the $profile notepad file
- Close PowerShell and Re-Open
- You should see a prompt similar to the image below
Once you’ve entered the environment, your PowerShell prompt should look like the below image
Verify Your Profile Environment
It’s wise to verify you got the profile paths correct. Test that the $profile applied the variables as expected by running the following commands
The information returned will be a semi-colon separated result including all current module paths. Your newly added path should be included in this
This should return the current directory your PowerShell session is set to right now. This should reflect your environment path you entered.
You should be able to see the prompt is different depending on the input you chose.
PROD = PROD>
DEV = DEV>
If I Entered “DEV” Do I Have to Close PowerShell to get into “PROD”
No, you do not have to close out, though it might not be a bad idea depending on all the stuff you add to the profile. You can switch easily by entering the following command
. $profile PROD
There is a little bit of error handling, but not much in this script so be aware that you will want to augment this script if you want more error handling.
What can I do with this?
The sky is the limit. If you want to have specific modules loaded or snap-ins you know you’ll use, go ahead and add them. Just be warned, if you add too much stuff, it could slow the overall load time down as well.
Check back to my blog, I’ll show you how you can create a desktop shortcut to automatically enter the parameter so you can quickly get into your DEV or PROD PowerShell profile without entering anything.
I’m back. Microsoft Ignite is over and now I need to pick up the pieces of my food choices. I started the week off relatively well. I planned to eat no more than 2,500 calories per day, which I came pretty close to the first 2 days. Then things went downhill. In the end, I don’t regret it. I don’t even feel that bad. Here’s the results of a week in which there was free food, drink and everything else.
Weight Loss this week: -4.8 lbs
Total Weight Loss: 43.4 lbs
I’ll admin, that doesn’t look too good. In the end, though, this isn’t that big of a deal. Here’s why. I don’t really believe I gained an actual 4.8 lbs. We all know it takes a little time for… um… your food to pass through your body. I’ll have a much more accurate picture of the damage I did this Sunday when I do my weigh in.
Today I am back on the 1,800 calories per day. I’ve already begun with my standard yogurt and granola breakfast. I’m hoping that being back on the controlled diet will help the way I feel. Eating whatever I wanted was starting to make me feel disgusting. Hopefully this will get me back to a better feeling.
Don’t worry about me folks. I may have had a seemingly large setback, but I’m back on track today. I may need to extend my challenge again so I can actually get down below 170 lbs, but that’s ok.
Have a great day everyone!
I’m not entirely sure what day it is right now, it’s 1:40am and I just got back to my room. I came from a super awesome party at Ignite in which, for the first time, the longer line for the bathroom line was for the mens bathroom, not the womens. Honestly (and I dont know why I had to say honestly) there were no women in the womens bathroom, none and probably about 40 in the mens. Common sense would have foreseen this considering, this is a Microsoft conference, so yeah, there are pretty much no women here. Ladies, you’ve got the pick of the litter here, if you like overweight, pimply, socially awkward nerds who would rather talk about creating PowerShell modules than anything else that could ever have been considered interesting ever in the world (sorry ladies, I’m taken).
Our awesome party (cynical sarcasm) had a bit of a circus theme. There were some interesting characters walking around, but the most interesting was the young lady doing contortion things. I really don’t know how to say it any better. It’s an impressive skill, but when you’re asked to randomly walk around a party of nerd and you’re going to lay down on the floor doing your bendy things, you’re going to attract a weird crowd. I found myself wanting to go punch all the creepy, drooly guys who just had to take a picture of this poor woman who’s just trying to make some money to pay rent by performing a skill that anybody could likely see if they ever set foot in a gym in their life and simply walked by the stupid yoga studio. Yeah, I can’t do those things, but I also don’t need a creepy, I’m old enough to be your father, but you’re paid to do this type of picture. Yeah, it’s been a long week. It’s Tuesday, and really, really late, and I’m rambling. My only saving grace is nobody, and I do mean nobody will read this, ever.
The worst part about all of this is I met a dude that would be a perfect fit for our team and we simply don’t have any openings and won’t have any. He was awesome and just as cynical and awesome as me and we cannot have this guy on our team. Oh well.
Did I mention we had the most fulgar cab driver who I thought was going to kill us? And that’s not even mentioning the Uber driver who literally did almost kill us, about 4 times. Wow! If that’s how an Uber cab is, I should probably consider waliking more
That’s all I’ve got. Enjoy those zero of you who are also up around 2:00am to read this absolutlely stupid and unedited post. Literally, I see the red squiggly lines for all the spelling errors, and could… not… care… less than I do right now Wow! I’m so tired.
Have a great night everyone.
Oh, I also did ok, well, just not terrible with my eating today. And done.
Sunday I head for the Microsoft Ignite conference, but that doesn’t mean my weight loss challenge stays home right?
I’m a little anxious about this one. I’m a food guy and I love Chicago food. Chicago style pizza, hot dogs, Italian, etc. It’s an opportunity to likely eat on someone else’s dime for 6 days straight. Not to mention all the free drinks and whatnot too. How does one, such as myself, stategize against this?
I have no idea actually. I’m planning on bringing my workout gear as the hotel we’re in has a pretty nice gym. Hopefully I’ll be able to get some workouts in either before leaving in the morning or late when I get back (morning is the better bet, but just barely). Food wise, I don’t have a lot of solid ideas. Yes, I plan to give myself a liberal daily calorie goal. I’m not there to lose weight, so 1,800 calories a day is just not going to suffice. I’m thinking 2,500. I may gain, but not so much that I’ll have felt like a complete failure. My other strategy is to do as light a lunch as possible. That means fruits mostly with perhaps an egg or meat option. Something with some protein. My other option is to load my hotel room up with an obscene amount of beef jerky so my mornings consist of fruit and jerky which will keep me going strong when the feasts begin at lunch and dinner.
Unfortunately, there is a large part of me, not so deep down inside, that wants to just say screw it and live large. Eat what I want, as much as I want and just deal with it when I get home. I thought that until I found out just how many calories there are in one slice of Chicago style deep dish pizza. It’s obscene.
What are your recommendations for me?
I am so excited. On Sunday I get to hop on a plane headed for Chicago for the Microsoft Ignite conference May 4th-8th. Of all the nerd inspired things one could do, going to a Microsoft technology conference has got to be at the top of the list.
I’m learning pretty quickly, though that nerds apparently know how to party, or at least to appear to know how to party. I’ve not been to a conference of this size, so having to pick and choose my after-hours entertainment from the slew of options available to me is a bit daunting, but a nice problem to have.
I, and my employer are hoping I’ll come away from this 5 day experience with some valuable knowledge, skills, and contacts regarding SharePoint, Office 365, OneDrive for Business, Skype for Business, Windows PowerShell and so many other technologies.
I’m not sure if I have any readers that are also going to Ignite, but if you are, what sessions are you looking forward too and what after-hours stuff are you hoping to do? I’m really hoping I’ll bump elbows with someone important who has extra tickets to one of the Wild vs. Blackhawks playoff games as I’d love to see my team when I’m in Chicago.
For those of you not a member of the nerd world of enterprise technologies, what are your recommendations for things to do in the great Windy City of Chicago USA next week? Any great restaurants you can recommend? We’re going to be downtown in the Michigan ave area so I’m looking for great ideas there?
If any of you are going, I’d say we should meet up and have a drink, but let’s be honest, are we really going to do that? Do you really want to meet me? Of all the people out there, I’ll be honest, it’s not going to be that awesome meeting me… ha ha or is it? If you’re willing to go to a midnight viewing of the new Avengers: Age of Ultron (2015) movie with me, then I’ll meet up with pretty much anybody, or you have tickets to the Hawks game, just don’t plan on murdering me please, that would be a pretty big downer.
Yesterday, I attempted to do my typical rowing workout, but found all the machines were taken. No worries, I’ll just go lift and by the time I’m done, there will be one open. Nope! That started my apparent demise for Monday and today. I wound up just doing my lift which was a shortened one and heading back to work.
Today was different. Had an all day meeting with some folks at Microsoft so there was no opportunity to do my workout at all. Ugh! Oh well right? They provided lunch which used to be my favorite part about these all day meetings. Today, I was nervous. Are they going to give us the super tasty deep dish pizza that I love, or the much healthier sub sandwich option. Whew, we got the sandwich option.
I can take a lot of positives out of the situation. Even without the workout, yesterday, I still managed to end the day with about 27 calories remaining. That’s pretty darn good, considering that put me just under 1,600 for the whole day. Today may prove to be a little tougher. As of right now, I have 682 calories remaining for supper tonight. Again, I need to take some positives from this. I have a lot of tools I can employ to ensure I don’t go over my calories. Stay tuned tomorrow to see how I do.
Sorry to leave you with such a cliff hanger. I’m sure you’ll tune in tomorrow to find out what happens.
Those of us who have the wonderful job of managing a SharePoint farm know, installing patches can be a bit like playing roulette. This is especially true when installing Cumulative Updates, but not limited to.
Those of us who manage a SharePoint farm with multiple servers have definitely seen our fair share of messages like the one below.
Obviously, the first thing you need to verify, is that the noted patch is actually on all the servers. If it is, often we are then directed by sites, even mine, to manually run some combination of the PSCONFIG.exe command manually via powershell. This typically works because we’re forcing SharePoint to skip important version checks etc.
I highly recommend before you jump to any powershell that you follow the instructions on the site below.
What this site is doing is clearing your configuration cache on each server before you attempt to run the SharePoint Configuration Wizard on any of your servers. The instructions specifically indicate they are for SharePoint 2010, but they work for SharePoint 2013 as well.
I’ve found I’ve even had issues running the PSCONFIG.exe manually and I still cannot get the config to finish. Clearing the cache is what works. You may need to reboot your servers, and you may even need to clear the cache twice, but soon, it will likely resolve the issue. So if you’re sitting stuck at 10% for forever, kill that PSCONFIG.exe task in the Task Manager and clear your cache. But don’t thank me, thank James Waymire, the author of the above article.