PowerShell Transcripts


Do you test cmdlets in a PowerShell window? Do you just do something that you know should work and it doesn’t? Have you ever thrown the kitchen sink at a problem and all of a sudden your script is working? I bet you just closed the PowerShell window you were working in and lost all that work, because I’ve done it before.

Well, once bitten, twice isn’t gonna happen. Why? Because I’ve added the Start-Transcript cmdlet to my profile. It’s that simple, no muss, no fuss. There are a lot of different parameters that you can set with Start-Transcript such as:

  • [-OutputDirectory <String>]
  • [-Append]
  • [-Force]
  • [-NoClobber]
  • [-IncludeInvocationHeader]
  • [-WhatIf]
  • [-Confirm]
  • [[-LiteralPath] <String>]
  • [[-Path] <String>]

I dislike the naming convention that is default with PowerShell so I have added the Start-Transcript with the following bit of code

$a = (Get-Date).ToString(‘Mdy’)

Start-Transcript -Path C:\PowerShell\Transcript\$a”_transcript.txt” -append

What I’m doing is storing the current date in a variable as a string of just the month, day, and year which when you run $a will look something like “4619“, which is April 6th 2019. I then start the transcript with the -path parameter to my powershell\transcript folder with the name 4619_transcript.txt. I also use the -append  parameter in case I quit my powershell session during that day. Using append will just continue with the same transcript and avoid an overwrite of the file or an error.

Overall this is for me is easier to understand and find. I hope this helps you and gives you some idea’s for improvements to what I’ve shown you. Let me know in the comments if you have any enhancements.

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.