Currently browsing category

Functions

Enhanced profile – Display my custom functions

Somehow, I can be compared to a goldfish : my memory is really, really poor… And I do eat fish! But no, I can’t help…
Sometimes I wrote a usefull function that I embed in my profile and some weeks after (ok, even the very next day) I forget about it… So, here’s my solution: list these functions in a MOTD way. Each time I open a PowerShell console, the list is displayed and my memory gets refreshed.

Get-VMsByClusterNode

Here’s a very simple but usefull function to have a view on which Virtual Machine is currently running (or not, there a State column!) on which node of a MSCS failover cluster.

Invoke-Sqlcmd

The Invoke-Sqlcmd cmdlet is a SQL Server cmdlet that runs scripts that contain statements from the languages (Transact-SQL and XQuery) and commands that are supported by the sqlcmd utility.
Great! Let’s use it.

 
But…
The term ‘invoke-sqlcmd’ is not recognized as the name of a cmdlet, function, script file, or operable program.

Get-Uptime

Here’s a simple function to get a “readable” value of the uptime for the local computer (by default, but there’s a ‘Server’ parameter), and the last boot date/time.

Get-UptimeDays | Get-Uptime

SafeCopy

A promise is a promise, here’s my second (planned) application around MD5 hash: a function to copy files and check that the MD5 hash of the copied file is equal to the MD5 hash of the source file.

SafeCopy | Check-MD5 | BruteForceMD5

Check-MD5

Here’s a great function to generate the MD5 hash of a specified string.

Let’s have a break

Have a break… No, no panda bears here! Sometimes, we want the user to aknowledge an information before the script continues. We …

Take a screenshot with PowerShell

Thanks to Jeremy on StackOverflow (http://stackoverflow.com/questions/2969321/how-can-i-do-a-screen-capture-in-windows-powershell), .NET allows us to take a screenshot programatically:

Subnet mask functions

Since I have no memory (it’s actually this blog’s main purpose!), here is a summary of the possible subnet masks: Subnet Mask …

Download file with progress

Thanks to Jason Niver on MSDN Blogs (Downloading files from the internet in PowerShell (with progress)), yep, we can download a file …

Write-LogFile

Here is a function to allow a script to log its execution. Output data into a log file. Options for path, extension …

Run-MySQLQuery

I’ve found this great function written by Thomas Maurer on his blog. It’s really usefull to automate MySQL queries.

Scroll to Top