UA-19884546-1

Hello!

I am a husband, a father, an IT Tech and an Investor.

I'm going to use this site to save information for later such as code, links and notes for family and friends and the odd photograph I've taken here and there.  I often look for new investment opportunities so will probably post the odd thing here about those too.

 

 

 

 

googlelinkedin

1
How’s your battery life?
2
Finding my scripts
3
Hunt the email addresses
4
Powershell (re) pinning applications to the taskbar
5
Windows 10 build 9926 update failing
6
Getting RSAT to work on Windows 10 build 9926
7
Uninstalling Internet Explorer
8
Photo walk in London #TRlondon2015
9
Tasker – Headphones profile
10
How to setup WinRM for Powershell remoting

How’s your battery life?

I have had to replace a few batteries recently so wondered if there was a way to find out ahead of time when someone’s battery was getting towards the end of it’s usable life.

After making a csv file with the following and saving it as new.csv:

SystemName,CurrentLevel, Checked

computer1,,XXX
computer2,,XXX

We  can then run the below code to remotely interrogate the batteries.  First we see if the machine is reachable, then we run a scriptblock on their machines to first get the maximum the battery will charge to, then get the designed maximum and work out the difference.  If it’s less than 60% we report it and move on to the next.

 

The next step is to work out how to update the csv file instead of doing it manually but at the minute that part is eluding me somewhat.

Hope it’s useful,

Finding my scripts

I’m forever losing scripts and having to re-do them so I’ve started adding a comment block to the top of them all which is searchable via another script.

Each new script now has in the description part a line starting “ScriptHelp – ” and is saved in a subfolder somewhere below this script here:

When run this searches all the .ps1 files and pulls out the filename and any description line starting with the above string.
Now I don’t need to keep telling everyone else which script does what and have an easy way to see if I’ve already written something for the job.

 

Hunt the email addresses

Often I’m asked to add a bunk of email addresses to a group or perform some other bulk job on them.  Almost never are the emails in a usable clean format just ready to use so I have to waste lots of time cleaning up the data before it’s able to be processed.

Copy this chunk of code into PowerShells ISE

Paste into $people your nasty block of text someone has given you and run.

Out will pop a nice list of all the email addresses found somewhere in there.

Powershell (re) pinning applications to the taskbar

A long time ago I set-up a rather large .vbs file to pin office and other applications to the TaskBar for Windows 7.  It wasn’t too intelligent and so with each new version or type of office the script needed changing.  Fast forward to this week and I’ve re-written it entirely in PowerShell.

This new version is much better and will search for the correct programs paths a little better and pin away.

Windows 10 build 9926 update failing

If you’re getting error 0x80070057 when trying to pull the updates try this registry fix:

 

Restart the Windows Update server or reboot and the updates should start flowing again.

Getting RSAT to work on Windows 10 build 9926

After a fair amount of digging around on the web I’ve finally come up with a working solution which will get RSAT installed on a machine that doesn’t have EN-us as the default language, mine is EN-gb

Firstly download one of these language files

  1. 32bit version
  2. 64bit version

Next press Winkey + R and run lpksetup  (that’s an L not an I)

Now follow this guide here which will walk you through the process of installing a new language then changing the default to EN-us.

Once this is done, download RSAT from here, don’t google it or you will likely end up finding the file which is 34Mb and not the 49Mb one.  Both have the same KB which is super annoying!

 

If you’ve got this far you can install RSAT then flip the default language back to whatever you started with.

Uninstalling Internet Explorer

For some reason Microsoft always seem to make removing this application difficult.  These commands however seem to work much better than using the GUI but there’s no surprise there really!

Example for uninstalling Internet explorer 9
  • Log on to the computer by using an administrator account or an account that has administrative rights.
  • Close all Internet Explorer browser windows.
  • Click Start, type cmd in the Search box, and then click cmd under Programs.
  • Right click and select Run as administrator
  • Copy the following command:
  • Paste the command into the Command Prompt window, and then press Enter.
  • Restart the computer.
Example for uninstalling Internet explorer 10
  • Log on to the computer by using an administrator account or an account that has administrative rights.
  • Close all Internet Explorer browser windows.
  • Click Start, type cmd in the Search box, and then click cmd under Programs.
  • Right click and select Run as administrator
  • Copy the following command:
  • Paste the command into the Command Prompt window, and then press Enter.
  • Restart the computer.
Example for uninstalling Internet explorer 11
  • Log on to the computer by using an administrator account or an account that has administrative rights.
  • Close all Internet Explorer browser windows.
  • Click Start, type cmd in the Search box, and then click cmd under Programs.
  • Right click and select Run as administrator
  • Copy the following command:
  • Paste the command into the Command Prompt window, and then press Enter.
  • Restart the computer.

Tasker – Headphones profile

After seeing a post here from James on Google+ which looked much better than mine I decided to delete mine and start again.

The end result is a new notification whenever I insert some headphones which has icons for all of my audio apps.  Whenever an icon is selected, the app opens and the notification drawer closes.  Then once the headphones are removed the notification is closed.

Here’s what it looks like:

Screenshot_2015-02-05-09-04-26

 

  1. PlayMusic
  2. PlayBooks
  3. Spotify
  4. YouTube
  5. BBCiPlayer
  6. BBCiPlayerRadio

To get the icons I used an app called ExtractIcons from the play store but to be honest the interface isn’t very good which makes selecting the applications you want very fiddly.

Apps needed to get this set-up working:

  1. Tasker
  2. AutoNotification plugin
  3. ExtractIcons (Optional)

Once you have both of these installed go ahead and download then import this profile from here: http://goo.gl/ThI0Ag

You’ll then need to edit the tasks to put your own icons in and link them to an application to open but this should get you started.
Hope it helps.

How to setup WinRM for Powershell remoting

To setup WinRM on a network do the following:

set the winrm service to auto start
Computer Configuration \ Policies \ Windows Settings \ Security Settings \ System Services
Windows Remote Management (WS-Management) set Startup Mode to Automatic

create a winrm listener
Computer Configuration / Policies / Administrative Templates / Windows Components / Windows Remote Management (WinRM) / WinRM Service / Allow automatic configuration of listeners
IPv4 filter: *
NOTE: You’ll want to narrow down this filter to your admin host(s)
add firewall exceptions to allow the service to communicate.
Computer Configuration / Policies / Windows Settings / Security Settings / Windows Firewall with Advanced Security

Create an Inbound Rule allowing the predefined group ‘Windows Remote Management’
NOTE: Open up the new rule and remove Private and public so you’re left just with Domain

 

To test run Invoke-Command -ComputerName <computername> -ScriptBlock {gci c:\}

or to run command remotely do:

Enter-PSSession <computername> and to leave type exit From the pssession you can copy msi files locally then run them as normal: msiexec /i mymsifile.msi /qn

More info about using credssp for unc’s here:

http://dustinhatch.tumblr.com/post/24589312635/enable-powershell-remoting-with-credssp-using

ExpertsExchange workable example below:

Copyright © 2014. Created by Mark. Powered by WordPress.