Quantcast
Channel: PS C:>(Get-Virtual).info » Powershell
Browsing latest articles
Browse All 33 View Live

Powershell – function to Query a SQL database

# Today’s quick and easy function is a simple one that I regularly use to query a SQL database. It will return an object containing the result of your query – so makes SQL access very simply from...

View Article


Script of the Day – Powershell Menu Select list

Sometimes you’d like to prompt a user to select an option from a list in Powershell . . try this:

View Article

Powershell – Script of the Day – Menu-Plus

Yesterday, we created a simple Powershell menu http://www.get-virtual.info/2011/01/26/script-of-the-day-powershell-menu-select-list/ Today’s script is a feeder for the menu, that allows you use any...

View Article

Script of the day – ping a range of IP addresses

Friday today, so just a quick and easy script . . nothing clever In PowerShell, ping functionality can be handled by using the ‘test-connection’ cmdlet, or simply using .Net A ping using...

View Article

Script of the day – writing to a cell in Excel

Ever needed to inject info to a cell in an Excel spreadsheet – repeatedly . . . you can do so from Powershell . . like so:

View Article


Script of the Day – changing ESX NTP servers

The following script will amend the NTP server settings for all ESX hosts in your VC

View Article

Script of the Day – import all VMs from a Datastore to VMWare ESX / ESXi

So your DC fell over . . but you have a copy of all your vmdks etc and would like to import them to a new ESX host . . The following script will run you through a series of prompt and then import all...

View Article

Script of the Day – shutdown your VMware ESX estate with PowerCLI

The following script is straight from http://www.virtu-al.net/2010/01/06/powercli-shutdown-your-virtual-infrastructure/ I have used it a few times and it is very effective and easy to use. BE WARNED –...

View Article


Quicker copies with Robocopy . .

So I was messing about with Robocopy over the weekend and I decided to re-run an old copy job, using a new Desktop. Strangely, my copy did not kick off like it did before. The problem – the new version...

View Article


Monitoring VM Logs – Nearly real time monitoring – Script of the day

Today’s Script of the day is not one of my own, but one I have used a few times in the past few weeks – and I figured I should post here as a reminder for when I next need it. Written by the scripting...

View Article

Script of the Day – Creating AD groups without QAD cmdlets

We’re automating some server builds and need to create AD groups to manage resource access to each Server (company policy) We use SCCM for deployment and I wanted to automate the groups (at build time)...

View Article

Script of the Day – remove duplicate lines in a CSV file

Friday today, so we’ll keep it short and sweet. Someone dropped me a CSV file recently and asked if there was a quick way to remove duplicates. Easy . . Sample source file: Script: Pretty basic stuff,...

View Article

Script of the Day – quick and easy VMware Powershell scripts

Today’s script of the day is more a collection of scripts (or rather an easy way of generating a bunch of scripts) Over at the VMware labs (http://labs.vmware.com/) they have released an awesome tool...

View Article


Script of the Day – new(ish) Powercli cmdlets Get-ESXTop – part 1

Ignore this post – found it written up far better than I could ever manage: http://www.lucd.info/2010/12/03/hitchhikers-guide-to-get-esxtop-part-1/#more-2790 When I have some time, I’ll write a wrapper...

View Article

Script of the day – testing if 2 IP addresses are on the same subnet

Ever needed to script around IP addressing issues on hosts and needed to determine whether 2 hosts are in fact on the same subnet or not? Try the following Function The code simply does a binary...

View Article


Script of the day – Powercli one liner to get ESX host versions

So I was looking at an ESX estate that is managed by someone else and was hoping to do a few ‘Get-EsxCli’ queries. Of course Get-EsxCli only works properly from 4u2, so I needed to find a host that was...

View Article

Script of the Day – Scripted start of Virtual Center (and supporting servers)...

There are many threads on the VM communities, debating whether it is better to run a VC on a physical host, or a VMWare host. My answer is always that running it as a VM is better, but the arguement...

View Article


Copying data to/from a VM datastore using PowerCli – Script of the Day

Ever needed to copy data from your local machine to a VMware datastore . .and not felt like messing around with winSCP / FastSCP, the Datastore browser etc? PowerCli / PowerShell lets you create a new...

View Article

Identifying SAN disk usage using WMI – Powershell – Script of the Day

So I was commissioned with identifying the amount of actual disk space used by a bunch of Microsoft Servers that were attached to various SANs on our network. Unfortunately, despite us having a rather...

View Article

Powershell – (Get-virtual).info – RSS Capture with Powershell through a proxy

a little geekery . . . As the blog is called ‘Get-Virtual’  . .I figure we may as well have a cmdlet / function to allow us to actually get the content of get-virtual . . . so I quickly put together an...

View Article

Finding VMs with disks on multiple different datastores – Script of the Day

I was looking at a VM on one of our hosts and noticed the rather odd configuration showed that the VM had 2 disks provisioned (not unusual), and that the 2 disks had been presented on different storage...

View Article


Using regular expressions to parse files in PowerShell – Script of the Day

How often do you find yourself needing to identify a string in a file somewhere. For example, you have a log file, or a config file and you know it contains an IP address, but you do not want to...

View Article


Opening a Port on a Windows machine using Powershell

Quick one today . . Someone in the office asked me how to quickly open a TCP port on a Windows host in order to do some firewall / port testing across vlans. I figured, let’s do it in Powershell –...

View Article

Powershell – Converting multiple return values to single strings for reports

Sometimes, you’re writing a little Powercli / Powershell code to generate a report and the repotr you generate retuns multiple values for some lines. for example, you want a report showing each ESX...

View Article

Querying BMC ADDM / Atrium from Powershell.

We have a new discovery appliance at a client site – BMC atrium. I was having a look at it and unfortunately it does not have a normal SQL backend . . so it is not as easy to collect information as I...

View Article


Useful scripts for amending the number of ports per vSwitch

We have found that on many (most) of our ESX hosts, we run at risk of running our of vbSwitch ports when we run through our maintenance periods and reduce the number of hosts in a cluster. Below are...

View Article

Finding an unsused IP address on a subnet using Powershell

I have been doing a bunch of P2Vs lately and sometimes when VMWare converter decides to not play along, I resort to offline conversions using Platespin convert. Platespin likes to have about 4 IPs...

View Article

Last boot time with PowerShell

Has to retrieve a bunch of boot times for a list of servers – quickly put together a function (I know there are many equally easy ways – but felt like retrieving info via PowerShell as part of a bigger...

View Article

Create ESXi Host firewall rules using PowerCli

Recently, I needed to create some custom firewall rules on ESX hosts (lots of them) – for some Syslog servers that were in addition to our existing Syslog servers. Here was my appraoach (note –...

View Article



Invoking SSH commands using powershell (kinda)

Sometimes, you need to fire SSH commands from a Powershell session. This is quite quick and easy if you have the right tools. First of all, get the Posh-SSH cmdlets off github:...

View Article

Powershell behind a Proxy server

so there I was, living in my Powershell session, when I stumbled across a cmdlet that looked kinda useful. I wanted a little more info, but when I ran “get-help ” – I discovered that my local help...

View Article

Who fancies knowing when the rugby is on?

Been messing around with some regex for some boring work related consumption of poorly constructed data – when I thought why not do something useful? Rugby world Cup is around the corner – let’s make...

View Article
Browsing latest articles
Browse All 33 View Live