Post TSM Logs to Slack

Using TSM as your backup solution, the way to know if your backup is ok is to check the logs. Now we all know that going through logs on a bunch of servers isn’t that much fun.
Let’s use PowerShell to read the logs, parse out the good stuff and post it to Slack instead.

All that is needed, enter your servers and update the webhook URL

The script will loop through the servers and read the logs.
The interesting part is between
— SCHEDULEREC STATUS BEGIN and
— SCHEDULEREC STATUS END

If STATUS BEGIN is not found a warning is posted instead.

The script (Send-TSMLogToSlack.ps1) is available on Github

This is what it looks like.

 

I have scheduled this to run every morning.
So I can sit back and enjoy that morning coffee while scrolling through the log channel.

Restore From TSM

When using TSM as your backup solution, the GUI is not the fastest way to do your restore. IBM even recommends using the command line when restoring a large amount of data. So, let’s do that.

The syntax for dsmc is not the easiest to remember, for example, to restore all under D:\Data this would be the command for the latest version.

C:\Program Files\Tivoli\TSM\baclient\dsmc.exe restore -inactive -subdir=yes D:\Data\* E:\Restore\

or, to restore from last week it would look like this

C:\Program Files\Tivoli\TSM\baclient\dsmc.exe restore -inactive -subdir=yes -pitd=04/07/17  D:\Data\* E:\Restore\

Let’s simplify this with a PowerShell wrapper.

Restore-TSMBackup.ps1

I’m using Start-Process to run dsmc, this allows me to redirect the output. I’ve chosen to put it in a text file in the Temp folder.
When the restore is completed, read the file and show the summary.

Output from script

 

The script is available on GitHub

 

Sync PowerShell profile with OneDrive

If you like me uses PowerShell, if not every hour but at least every day. You end up tweaking the PowerShell profile, making your own aliases, functions and so on.

Now that is awesome, but wouldn’t it be nice to have it sync’d between all your devices?
I think so, so let’s put it in OneDrive 🙂

I hope this code is all self-explaining, just put it in your profile (Microsoft.Powershell_profile.ps1)

Although I don’t put my functions directly in the profile. I have them in a separate module.
And since I never remember witch functions I have, I’ve put this in my profile.

Hope you find this useful! 🙂

Keep on script’n

Andreas

Build a simple ConfigMgr report with PowerShell

If it’s more than one person working with Configuration Manager (yeah like you do it all by yourself ;).
It can be hard to keep up, a new application added on Monday, a Package modified on Tuesday and 3 new Configuration Items on Friday.

This script will hopefully makes it a little bit easier to keep up.

The Basics

1. First we need to gather some information

2. If something is returned, add it to a text file with a little html formatting

3. Send it as a nicely html formatted email.

I run this script (scheduled task) every Monday morning, perfect reading while enjoying  my morning coffee 🙂

The Script

Happy PowerReporting Andreas 🙂

PowerShell GUI: Create ConfigMgr DriverPackages v 1.0

It can be a real hassle creating new Driver Packages, especially if you want to have some order in your repository.
If you don’t want to go ‘all in’, like when you’re using the Coretech tool: this little script that I’ve created might come in handy.

The idea is pretty simple, just enter manufacturer, os and model,
and the script will then:

  • create a folder: DriverSource OS  Manufacturer  Model
  • create a folder: PackageSource OS  Manufacturer  Model
  • create a new Driver Package
  • create a new Driver Category (optional)

all with the right names and in the right location… neat huh?

 The Script

The Script reads settings from Settings.xml, located in the same folder as the script.
If it doesn’t exists, it’ll be created.

The first time the script runs it will automatically go to the settings tab.
(no need to modify the xml file manually)

The What If button shows the commands that will be executed.

Now go ahead and create some Driver Packages 🙂

Requirements

You need the ConfigurationManager PowerShell Module available.
If you don’t have the ConfigMgr Console installed,  you need to modify the Import-Module command.
I’m using the following line:
Import-Module ($env:SMS_ADMIN_UI_PATH.Substring(0,$env:SMS_ADMIN_UI_PATH.Length – 5) + ‘ConfigurationManager.psd1’)

The End

I’m using PowerShell Studio by Sapien to build the GUI, it really simplifies the process.
If you haven’t tried it, I really recommend that you do so.

And here’s the link to the script, it contains both the .ps1 version and the PowerShell Studio project file…

I’d really love to hear your two cents…

/Andreas

PowerShell Profile + ConfigMgr = Love

Something I’ve learned: a quick way to access your ConfigMgr cmdlets is awesome 🙂

Now that’s not so hard to achieve, place the following function in your PowerShell profile.
(A great guide to the profile over at How-To Geek)

Now all we have to do is call the Load-CM to have some fun.

 

Create IP Range Boundaries

I had one task that I kept doing multiple times, to create new IP Range Boundaries.

Then I found a really nice function at CM12SDK.net, and after some small modifications it was fit for the job.
I didn’t wanna write Site Code and Site Server for every new boundary, so I simply hardcoded them instead. And yes, it’s OK to be lazy.

In order to save some extra time (be extra lazy) I added the new boundary to the default boundary group.

Now it’s fast and easy 🙂

New-IPRangeBoundary -DisplayName “Range 007” -Value “192.168.7.2-192.168.7.17”

 

List you’re Boundaries

Now that you’ve hopefully created some boundaries, maybe you’ll want to list them as well?
Here is a simple function to do that:

Get-IPBoundaries

/Andreas