Write-NTSPLog

Write-NTSPLog

Hi Everyone,

OK, so this is the first function I’ve uploaded in a while, I’ve been quite busy at work but I had to share this one as it’s very useful, and could be very useful to a lot of people. So here goes. :/

The function is fully commented and contains a comprehensive help section so you should be able to understand what it dose without reading this explanation.

This information can then be used in something like PowerBI to utilise it in a dashboard, i’m planning to make a guide so stay tuned!

Synopsis

So the basics is it’s a logging function that adds items to 2 SharePoint lists on the connected site.

One of them being an Overview of the process it’s logging the other having each event individually stated.

Detailed Overview

The function appends(or creates) 2 SharePoint lists, one is used as an Overview of the running processes (be it scripts or Workflow or anything running a series of commands) with information specified in the function parameters and the other a log of each action taken.

The “LogList” and “OverviewList” list are linked together by the Overview’s “ID” field generated when it’s created, passed by the -Passthru switch, this is then in turn referenced using the -ID parameter that’s populated in the “OverviewReferenceId” field, the function populates a new list item with the values of any specified parameters, most of which are optional.

These parameters are;

OverviewList“,”LogList“,”ProcessName“, “Step“, “CurrentStatus“, “Result“, “ProcessOwner“, “ProcessObjectCount“, “ProcessObjectCurrentItem“, “TargetObject“, “CommandRun“, “OverviewReferenceId“, “RunBy“, “HostSystem“, “ConnectedWithAccount“, “Errors“,”Notes“,”Passthru“,”SkipCheck“,”PreBuildLists“,”ID

So the first command in a process would look something like;

and each item in the process you’d like to log would look something like;

or

Notice that the first command stores the return value from using the -Passthru switch to a variable and then the following commands uses that variable in the -ID parameter, this essentially updates the OverviewList list item of that value with the values in the parameters stopping another OverviewList item.

There are a few Switch parameters;

Passthru“,”SkipCheck“,”PreBuildLists

This returns the OverviewList list ID number for use in subsequent uses of the function in the script.

This is useful to specify after the initial run on the function as it skips the checking portion of the function.

You can call this anywhere as it just builds the list in the connected site without adding any list items. (if you just want to see how the function creates the list or to pre-create them.

Default Parameters

SupportsShouldProcess is set to True and ConfirmImpact is set to High, this is why I use -Confirm:$false in the examples, this is is just a precaution as the function creates SharePoint lists in the connected site.

Required Paramters

OverviewList“,”LogList” are both required and reference the lists your logging will go in to.

Parameter Info

ProcessObjectCount“, “ProcessObjectCurrentItem” require an [System.Int32] (a number) and are optional.

Passthru“,”SkipCheck“,”PreBuildLists” are Switch Parameters and optional

The rest require [System.String] (Text) input and are optional

Output

Default output of the command is [System.Void] or if -PassThru is specified [System.String]

Other Information

I use a function in the scrip called ConvertTo-CapitalSplit this is something i created just to Split By the Capital when converting the internal listed names to the displaynames.

Requirements

This function uses and requires the module SharePointPnPPowerShellOnline

on systems running Powershell 4.0 and above can run the following commend to install it;

or instructions can be found at HERE

The function itself requires a minimum of PowerShell Version 3.0

You need to make sure that yo’ve handled the SharePoint connection yourself prior to calling the command.

Usually you’ll use something like;

$Creds being the created elsewhere in the script.

Function Functionality

So most of this is covered above but i’ll try and give you some example of how to utilise this function.

This is something i created to manage our O365 E5 licensing, as you can see the function is used in several steps and gives me details on whats happening in the script.

I’ve redacted all sensitive information so if you’d like to plagiarise the script (:p I don’t mind) you’d have to adjust it to your own needs.

The actual function

So here it is, I hope you find it useful, i’ll try and update as suggestion come in.

Credit

SharePoint related queries – James Beckenham – Senior SharePoint Specialist

Invoke-NTClientAction

 

Get-NTVMWareStorageCacheStats

 

System Checking Tool

Hi everyone, so I’m posting this system checking tool I created as requested https://www.linkedin.com/hp/update/6268497385098346496 which was written in PowerShell using Sapiens PowerShell Studios.

I created this to assist with our monthly patching at Cancer Research UK, it was put together relatively quickly so will contain bugs but it’s functional for what we need.

Some of the features are;

  • Testing to see if the device is reachable via ping
  • Testing if the device is responding on the RDP port 3389
  • Return last reboot time and state if it was recently
  • Selecting individual rows and rechecking through right click menu
  • RDPing to selected rows
  • Extended tests return updates count and click able link to display them
  • Update windows give vital update info and who install them.
  • clickable host-name link brings up system info.
  • System info includes disk info an other system details
  • System info screen allows to view logged on users
  • Allows you to log off individual users or all of them
  • System info screen allows to to restart the system.

There is a menu item for help, but it dose nothing at the moment.

 

I’m planning to integrate this in to my C# project at some point so this’ll be obsolete when that comes out 🙂

Link to ZIP of the EXE

You might need to allow the app through the AV as some pick it up and a risky code etc..

 

Below is the exported code for reference, it’s pretty rough, not a great example, but functional;