What Version am I Using?


The other day I was doing a quick one-liner on a bunch of DMZ servers when a few of them failed. At that point I wondered if I had updated the older servers powershell version. So, I threw another quick one-liner at them to get the powershell version. No fancy stuff, but I always get asked by colleagues “how do you know what version of powershell you are running?” So, I tell them an easy way to remember $PSVersionTable, which is “You are trying to find the PS Version in Table form stored in a variable,” which adds up to $PSVersionTable.

psversiontable

You can see above that when I output this as a variable it is in table format. Also, if you look at my menubar, I actually have the psversion written to it. That is done in my profile along with some color changes and starting a transcript of the session. Easy, one-liners always makes my day.

 

Office 365 Limiting PowerShell


A quick post on my frustrations with Office 365 limitations on PowerShell. In Exchange Online with ATP I’m using Spam and Phishing filters to quarantine bulk mail and phishing attempts. While it is working quite well there is a 100 bulk limit on deleting in the GUI.

That’s not much of a surprise, but I was utterly stunned when I ran a one-liner script to get the quarantined emails for 1 day and pass them to the: delete-quarantinemessage cmdlet that it also seems to have the same limitation as the GUI. That can’t be possible, really? I plan on some searching in the next few days to confirm this, but I’m just stunned at this.

Off to get a Corona or two to let this sink in. Until the next time have a beverage of your choice and enjoy.

New Year Get-Help


This being a new year and not posting in over a year I decided to create a habit of writing once a week about PowerShell, or another technology topic. I have also decided that I am going to focus completely on technology, staying away for all other topics, including family.

Let me state that I am in no way an expert in PowerShell, in fact I’m far from it so I’m learning as you are learning while I write this. I’m doing what Don Jones has talked about in “Be the Master” which is you can be the master by giving back, by writing what you are learning to help other people.

With that, let’s move to the beginning of PowerShell and the best way to learn about cmdlets and how to use them. In fact it’s a cmdlet thats built into PowerShell called “get-help”. That’s easy isn’t it? Well yes, it is, but it is very multifunctional, has many different options, and at times confusing. In this post I’m just going to start with the first basic usage and in the next few posts go into detail. Get-Help in its most basic form without any parameters looks like this using the “get-service” cmdlet:

PS C:\Powershell> get-help get-service

NAME
Get-Service

SYNOPSIS
Gets the services on a local or remote computer.

SYNTAX
Get-Service [-ComputerName ] [-DependentServices] -DisplayName [-Exclude ] [-Include ]
[-RequiredServices] []

Get-Service [-ComputerName ] [-DependentServices] [-Exclude ] [-Include ] [-InputObject
] [-RequiredServices] []

Get-Service [[-Name] ] [-ComputerName ] [-DependentServices] [-Exclude ] [-Include ]
[-RequiredServices] []

DESCRIPTION
The Get-Service cmdlet gets objects that represent the services on a local computer or on a remote computer, including running
and stopped services.

You can direct this cmdlet to get only particular services by specifying the service name or display name of the services, or
you can pipe service objects to this cmdlet.
RELATED LINKS
Online Version: http://go.microsoft.com/fwlink/?LinkId=821593
New-Service
Restart-Service
Resume-Service
Set-Service
Start-Service
Stop-Service
Suspend-Service

REMARKS
To see the examples, type: “get-help Get-Service -examples”.
For more information, type: “get-help Get-Service -detailed”.
For technical information, type: “get-help Get-Service -full”.
For online help, type: “get-help Get-Service -online”

This give you the basics:

  • The Name
  • The Synopsis
  • The Syntax
  • The Description
  • Related Links
  • Remarks

I’m only going to go over the Name, Synopsis and the Remarks in this discussion, with the others in later posts. Let’s start with the obvious “Name”, which is the name of the cmdlet we are getting help on which in this case is “get-service”. Next up is the “Synopsis” which is a brief description of the cmdlet, in this instance get-service “Gets the services on a local or remote computer”. These two are self-explanatory, really not needing any further discussions.

The last part of Get-help that I want to touch on is the “Remarks” because this is a great source of help before you understand the syntax of the cmdlet. By typing a parameter at the end of your get-help cmdlet you can see examples, a detailed view, a full view which is detailed with the addition of input and output object types, and additional notes, and finally the online view which will take you to the docs.microsoft.com page for the cmdlet.

I said finally when I was talking about the online parameter which really isn’t the last way to view help for a cmdlet. The “Show Window” parameter will open a separate window that you can scroll through the help for that cmdlet. It looks like the picture below. I prefer “get-help get-service -ShowWindow” because I get everything in a separate window that I can leave open, and don’t lose anything to the buffer of the PowerShell Window. It also lets me continue to try the cmdlet in various iterations while switching to the window to see the help by itself. Less clutter, easier for myself to work with. You may prefer another parameter like Examples which I use when I really understand the cmdlet, but just want a refresher on the common uses.

That’s the beginning of Get-Help. My next post will start to go into the Description and the Syntax of Get-Help. Let me know in the comments if you have any questions, constructive ideas or tips of your own.