A little corner of the Empire on the web.

Showing posts with label VBScript. Show all posts
Showing posts with label VBScript. Show all posts

04 July, 2017

Retrieve LAPS (Microsoft's Local Admin Password Solution) details using VBScript

History

We've been Microsoft's LAPS (Local Admin Password Solution) as a solution to manage the local administrator passwords on the majority of our servers (excepting domain controllers, for obvious reasons) for a while now. The fact that we'd been living with all of our servers having one or two incredibly simplistic passwords that hadn't changed for the best part of a decade, was giving us so many potential problems, from the ex-employee knowing the all the keys to the kingdom problem, to the straightforward pass-the-hash attack, and LAPS has worked well to mitigate those problems. For our server admins the options of reading the raw password from ADU&C, or using the PowerShell module, or even using the barebones LAPS GUI were fairly straightforward.


The Present

Now we're expanding our LAPS usage to manage the local admin passwords on all of our desktops and laptops. I know that most companies roll LAPS out to their laptops first and their servers last, but the fact that we'd been regularly changing the admin passwords on our laptops and desktops roughly twice a year for years meant that it wasn't needed so badly there.


For our desktop admins, and our helpdesk staff, we can't just point them at the installer for the PoSh module and leave them to it, so we're giving them the LAPS GUI client, but also integrating LAPS password lookup into some of the existing tools that we provide them. This means that I needed to retrieve the LAPS info using VBScript, rather than PoSh, to integrate into one of these tools. All of the examples in the LAPS documentation, and in everyone else's web write-ups of LAPS, use PoSh, so I had to pull this together from a few other scripts and tools that I'd used.




Download


Download the script here: GitHub: LAPS-Password.vbs



12 June, 2013

Kindle Weather pt2 Setting up the server

Back to the first post in this series

Setting up the server


Matthew Petroff's original scripts assume that you're using a Linux server, they're made up of a BASH shell script (that won't do anything on a Windows box) and a Python script (that needs an extra install of 3rd party software to get it working on Windows), as well as relying on a couple of small tools that either aren't available to us, or don't work as well on Windows.

So to get things compatible with pretty much any Windows box, I've rewritten the shell script as a batch file and the Python script as VBScript, both of those should just work on anything from Windows 2000 upwards, and I've found some replacements for the small tools.

What you'll need for this section:

Create a new folder somewhere on your server (preferably outside of your web server's root) and download and extract the zip file into it. This should give you three folders, one of which is called "Server-VBScript", and in there are three folders called "ServerNOAA", "ServerWU" and "ServerMet" inside each of these you'll find an SVG, CMD and a VBS file. Now you need to decide which weather service you'll be getting your forecasts from, they all make their data freely available for non-commercial usage but have different coverage, may differ slightly in their forecasts of different areas and provide slightly different info, whichever one you want copy that service's folder into the new folder on your server:

  • NOAA - the US Government's NOAA's National Weather Service. The major downside (for me) is that they only provide forecasts for the USA.
  • WU - Weather Underground, run from a US University, they provide worldwide coverage, and in multiple languages
  • Met - Her Majesty's Government's Meteorological Office (The Met Office) forecasts. They only cover the UK (this is what I'm using on my Kindle)

Pick whichever weather service you want, and feel free to delete the other folders if you don't want them.

Weather Services


Depending which weather forecast service you pick, you'll need to find your location code, and possibly sign up for a (free) API key to use it, I'll go though these:

NOAA
All you need is to find the latitude and longitude of your location, and change these in the long URL inside the ServerNOAA\weather-script.vbs file using a text editor, also note that the final parameter in that URL "&Unit=e" sets it to the temperature in Fahrenheit, changing it to "&Unit=m" will output the temperatures in Centigrade.

WUnderground
You will need to sign up for a developer account at Weather Underground, and then you can create a (free for the usage level that we'll be putting it to) API key to access the weather reports. Once you have that you just need to work out your city's code, acceptable formats are:
CA/San_Francisco | US state/city
60290             | US zipcode
Australia/Sydney  | country/city
37.8,-122.4       | latitude,longitude

Then open up ServerWU\weather-script.vbs file using a text editor, find the line with the long URL in it and replace "APIKEY", "COUNTRY" and "CITY" with your API key and location.

Met Office
As with WUnderground, you'll need to sign up for a free API Key to use the Met Office's forecasts, once you have that you can visit the following URL to get a list of the location codes that you can use:
http://datapoint.metoffice.gov.uk/public/data/val/wxfcs/all/xml/sitelist?key=API_KEY
Take the 6-digit location code from there, and your API key, and plug them into the long URL in the ServerMet\weather-script.vbs file using a text editor.

If you've got everything set up right, then when you double-click the VBS file it should create an SVG file in the same folder, showing your graphical weather forecast. You can view this SVG file with most web browsers.

Getting the Image Tools

(Side-story, looking for a suitable replacement for the RSVGconvert *nix tool to do command-line SVG to PNG conversions I went straight to my old, faithful ImageMagick, but every version of that and every option I tried seemed to choke on the embedded icons, eventually I came across Inkscape and discovered it had a decent command line interface, so here we are)

Next download Inkscape SVG editor and extract it into an Inkscape folder in your server's weather folder.

Then download PNGCrush and save the file in your server's weather folder.

Your folder structure should now look a bit like this (the "public" folder won't have been created yet):


Then go into the folder for the weather provider you're using, open the CMD file and edit it to reflect the paths of all these tools, and change the references to the "public" folder to point to the location of the folder within your web server's root that will be serving up the PNG image.

Now try running the CMD file in your chosen folder by double-clicking it, and with luck after a few seconds your 'public' folder should now contain a PNG image that looks a bit like this:

typical English weather

Scheduled Tasks


Finally you'll need to decide how often you want your weather image to update and set up a Scheduled Task in Windows to run the relevant CMD file as often as you want it. Personally I'm going to have my Kindle updating its weather display 4 times a day, so I'm setting my scheduled task to run every 6 hours.


Download the Scripts

  • GitHub project: all files for the project browsable online, and individually downloadable
  • Entire project master.zip (72KB zip compressed file): if you don't know what a GitHub project is, use this link to download everything needed in one go.


Update 07/2016: files and download moved to GitHub, all previous updates merged in.



Next: Setting up the Kindle.


  1. Introduction
  2. Setting up the server
    • Weather Services
    • Getting the Image Tools
    • Scheduled Tasks
    • Download the Scripts
  3. Setting up the Kindle
    • Jailbreak your Kindle
    • Setting up USB Networking (1)
    • Setting up USB Networking (2)
    • Installing Kite on the Kindle
  4. Putting it all together
    • Setting up the Weather Display on the Kindle
    • Setting up Cron on the Kindle
    • Useful References and acknowledgments
    • Todo