Tech Support

PowerShell: Advanced Profile

Posted on

In my last post almost 6 months ago I spoke about PowerShell profiles, especially how I preferred a simple profile. If you are just doing some simple things that you need right away or aren’t administering an application like Azure, SharePoint or Office365 then you can suffice with the simple profile. Since I manage Office365 and the applications mentioned above I have morphed to a second profile that I now load to load everything that I need for those applications. The time entering my username and password for those accounts, saves on having to load a different PS1 or create a function to do it later. My thoughts about not creating the function is if I do it once the first time I can just continue working without stopping when I need to do something in those applications.

My previous profile looked like this:

set-location c:\Powershell
$a = (Get-Host).PrivateData
$a.ErrorForegroundColor = “green”

Just your basic profile that sets my default location, and sets the color of the evil error message RED to easier to read GREEN on the blue background. Now for my work within all of the applications that I admin this is the profile I use:

set-location c:\PowerShell
$env:path += “;C:\PowerShell”
$host.ui.RawUI.WindowTitle = “Administrator – Sysadmin Mode”
$Shell = $Host.UI.RawUI
$a = (Get-Host).PrivateData
$a.ErrorForegroundColor = “green”
import-module MSOnline
Import-Module AzureAD
Import-Module AzureADPreview
Import-Module ‘C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell’
$cred = Get-Credential
Connect-MsolService -Credential $cred
Connect-AzureAD -Credential $cred
Connect-SPOService -Url -Credential $cred

So, that is a lot more involved, but I only interact with the loading of the profile once at the line: $cred = Get-Credential, which is where I enter my credentials for Office365. Obviously our AzureAD is connected to Office365 which includes our SharePoint too so I only need to enter my credentials once.

First a disclaimer: I close this profile shell when I leave the computer even though I lock the computer screen.  This is best practice so that if anyone gains access to my workstation, they do not gain access to my Sysadmin account in PowerShell to do damage. We change our passwords on a regular basis to prevent access as is also best practice, but anything you can do to lower a hackers attack surface the better.

So, what does this all do? Well that is a pretty good question.

  1. I set the default location of my console as my PowerShell folder that contains all my scripts.
  2. I add the PowerShell folder to the system path
  3. Change the title of the shell to let me know I am running in Sysadmin mode.
  4. Set the system shell as the current console
  5. Set the error color to green
  6. Import all the Modules I need to make sure they do get loaded, including the SharePoint Module that is an MSI install
  7. Store my credentials for this session for use logging in
  8. Connect to all the services using the credentials I supplied. The SharePoint SPOService would need you to replace the word “company” with your company name.


I believe that this front end work saves me a lot of time when I have to do something in SharePoint or the SAAS client or AzureAD.


Can’t Control It All

Posted on Updated on

controlAs a Systems Administrator I am always working on applications and different projects that affect many different systems and end users. I am always focused on getting the job done on time and for the students who depend on what I do for their education. Sometimes my plans or the set goals for a project depend on other people.

It’s at that time that I have just recently found that I can’t control the outcome. Even though the project is mine as the technology lead, I can’t do it all and I cannot always make decisions that need to be made, happen when I want them to happen. This has led to a change in my thought process on how I am going to approach projects in the future. What am I going to do?

I’m going to do my part, lead to where I can then pass on the direction to the other parts of the project that I cannot control. When those parts are complete I will take the project back up to completion. I can’t be the person always prodding or emailing that this or that needs to be done.

School Year Ramps Up and Do What You Can

Posted on Updated on

I am enjoying my last long weekend before teachers come back on Tuesday the 14th. As a 12 month employee I work over the summer vacation doing 4 day weeks, 10 hour days. I’m one of the few people that does not like the 4 day week because while it ends up being the same amount of hours for the week as a 5 day week, you really can’t get everything into that 4 days that you can in a normal school year week. One reason is that we have projects that take a lot of planning and not just one project, many that all have time limits that your work is dependent on other departments. Teamwork and timing are extremely important. I miss the extra day.

The most important part of the year are the next 2 weeks, teachers next week and students the week after that on the 20th. It’s full of work, no matter how planned out you make it, you can’t rely on that plan. It really is just a wish list of things you want to do because there will always be something that makes it so that you cannot do any of your list. That is where the “Do what you can” comes in. If you worry about getting everything done, pleasing everyone then you will fail. Not only will you fail, you will make yourself sick worrying about it.

What are the most important things to remember?

  1. Do your best
  2. Do what’s important
  3. Smile in the face of adversity as all hell breaks loose around you
  4. It will all be there tomorrow