#
New-ShortURL Powershell Module
Simple yet no module is currently publically available for this
#
Powershell Function 👨💻
Pow, again I just boshed together an advanced function that uses a simple API call to retrieve a brand new short URL link from hideuri.com to turn a full length URL into a very short URL. Again I find an API where you do not need to sign up to obtain a key to be able to use the API. The good folks who provide this API for free just have one limitation, which is 100 calls per minute. Which I think is more than reasonable.
So why have you gone and done another module? Well dear reader, I spotted a gap on the gallery. I personally could not find any modules offering to make a full length URL into a short URL. So I was like damn really? No-one has done this yet? Nope not from what I could find.
This got me straight on the case, to find an API which would allow me to do this and without having to sign up to anything, as no offense I thank you for reading my blog, but to me giving out an API key is like giving you my car keys, and I need my family motor. No offense to your driving skills or nothing, just like I am sure you would not want me to randomly borrow your car. Get what I am saying? It took me more time to find the website I needed, than it took to build the module. Yeah so already in my head on productivity I was down a bit as I needed to make up time for the time it took to find the API which did not require a key.
I have used sites in the past if I am running out of space on a tweet, or something similar to make the full length URL into something smaller to allow me to make the post. I am sure you may have also found yourself in this very same predicament. Like me you probably opened a browser found a site and got the web browser you were using to do the dirty work
Again not that I am against using a browser, but it is wasting time at the end of the day. I do not do this all the time crunching long URLs into short URLs, but I have done it more than once, and as I am writing more blogs I will probably be doing it more often. This to me then gets a brain cell activated one of the few I have, to then make this task into an automated task, so I can do it in a jiffy as I mention in the help description.
Just in-case you missed the last blog, or you are just reading particular blogs, or this could possile be your first blog let us just quickly go over an API again...Please skip if this if you already read it in the last blog...
#
API ℹ️
You may or may not know about API aka Application Programming Interface. So here is some brief documentation
API An application programming interface is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how to build or use such a connection or interface is called an API specification. A computer system that meets this standard is said to implement or expose an API. The term API may refer either to the specification or to the implementation. In contrast to a user interface, which connects a computer to a person, an application programming interface connects computers or pieces of software to each other. It is not intended to be used directly by a person other than a computer programmer who is incorporating it into the software. An API is often made up of different parts which act as tools or services that are available to the programmer
So come on Adam what does that mean in cave man talk. Well to a simple person like me it would be like going to a McDonalds drive through with no queue and everything just waiting to be given to you. Still not making sense? Okay to me it is the fastest way you can possible achieve the specific answer you are looking for. So yeah maybe I could have downloaded some software to run this for me, but trust unless the program is using an API then this will give you results quicker than the program could. Or like if I was to do this manually, just the processing power and memory that firefox.exe uses on my laptop, it would be slower going via the web than it would for me to make the API call, the result is instant. I know not everyone out there has a 10 year old crappy x86 laptop to do all this experimenting on, but trust if it runs super fast on my laptop (which it does) it should be lightning fast on your nice x64 solid state drive stupid amount of ram machine. In a nutshell that is why to use an API for the task, and secondly to my knowledge APIs are normally only serving one purpose to keep them super fast. By one purpose I mean an API to find train times...It is not going to tell you what the weather will be like, or the services available on each train, it will just give you train times. I hope this paragraph has maybe made more sense than the official wiki guide above.
#
New-ShortURL 🦐
Before I made a plonker of myself be using a verb like GET for this task, like I may have done for a certain secure password generator. I do not like to make mistakes, and making the same mistake more than once is not how I like to roll. Not that I needed it this time, but folks please remember don't mess up your verbs, they are important to help the person using the cmdlet or function what that cmdlet or function is going to do, by the verb in the name. If you are confused or thinking what the shell is this guy talking about then please check out the link below:-
Shout out to my mate Sensei Steve at the Microsoft Powershell team
#
Top Tip Add Decent Help 📝
Due to the UK 🇬🇧 still being incredibly hot at the moment, and the fact we don't have fancy air-conditioning it has meant me getting to sleep has taken a bit longer than usual. So instead of just laying there thinking I'm hot, I'm hot, I'm really hot. I been spending my evenings making some new modules, then writing a blog on it. I do feel very creative late at night, so try to use that creativity to do something positive, I can over-look certain things. Like adding a proper help to the module. So this time round I made sure I added a decent help message for one parameter that is used. And a whole two examples.
NAME
New-ShortURL
SYNOPSIS
Turns a full url into a short url
SYNTAX
New-ShortURL [-FullURL] <String> [<CommonParameters>]
DESCRIPTION
The one and only Powershell short URL generator. This is using an API which is limited to 100 calls per minute.
Allows you to turn a full url into a short url in a jiffy.
PARAMETERS
-FullURL <String>
Is expecting a string with the complete URL so for example https://adam-bacon.netlify.app/misionimpossible/ is
a complete URL so I need to enter everything that would be displayed in the browser URL for this module to work
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
Super easy way to generate short urls
-------------------------- EXAMPLE 1 --------------------------
PS > New-ShortURL -FullURL "https://c.tenor.com/BC-pwUamRsUAAAAM/tiny-small.gif"
-------------------------- EXAMPLE 2 --------------------------
PS > New-ShortURL -FullURL "https://docs.microsoft.com/en-us/powershell/scripting/developer/cmdlet/validatepattern-
attribute-declaration?view=powershell-7.2"
Attention
Please see the description in the module and do not take the biscuit on this free service. Thank you for coding responsibly.
#
I hope you had fun 👋
Hopefully this module will reach out to more users than previous module may have. As always I like to try and keep things interesting, and to try and make something unique and useful as the end module product.
Well it has literally just gone past midnight so I really need to get my beauty sleep, as I now got to think about what I can do for my next blog, I am finding these a blast doing them, as it is so easy using this Powershell retype module to produce these documentation blog pages on the stuff I am working on. I do all the typing in notepad, so if you have noticed a good few spelling mistakes, that is why, because I literally sit and type out what is going on in my brain. So these blogs do not take to long to produce, as I like to think I can type at a decent speed, and it is far more quicker than me ever attempting to document this on paper then type it up. But weirdly I have worked with enough people who do things in such a fashion.
Maybe this last little paragraph might tempt you to get using this retype module and get creating weird and wonderful blogs like this one. Or maybe to use it as your in-house documentation product, potentially saving your company big bucks, and maybe earning you a new job to show the masses why are they doing things the hard way? Hopefully you will not loose your job in your proposal idea as I cannot afford to get sued by anybody.
Again thanks if you made it all the way here to the bottom of the blog, either you are a very dedicated reader, or maybe I just did not type enough content this time round to drag it out. Either way stay safe until next time.