January 1, 2012 at 12:00 am #6010
by maverick918 at 2013-02-01 12:02:23
First time Poster. Excited to be apart of the community.
I was curious if anyone on here has run into this issue before. I spin up multiple servers a day, anywhere between 10-20 a week, and logging into each server, going into disk management, and then formatting and lettering/labeling each disk takes a long time, especially if the server has 14 drives. I want to use PowerShell v2 because that is the default for Server 2008 R2 and Powershell 3 isn't in our standard build.
I'm wondering if any of you have run into this issue, unfortunately diskpart does not allow remote interactive sessions and Invoke-VMScript does not allow interactive sessions (only returns raw-text). So those two avenues are out. To add another layer of complexity there are different tiers of storage that these disks could be apart of. For example: a 30 GB disk 5 could be on a different storage tier as a 30 GB disk 6, but they look the same to the OS. Get-VMDiskMapping in the PowerCLI reference book could potentially work to get the storage tier (as it is designated in the LUN Name). Look it up on Sybex's website. Its in Chapter 7
Here is what I'm thinking (and let me know if I'm nuts)
Query each server for the disk# and size (essentially "list disk | diskpart")
then do a Get-VMDiskMapping and then match each disk# from disk part output to the VMDK and storage tier.
From that info build a custom array only with the following info
Disk#,Storage Tier, Label and Letter (Label and Letter will be from a CSV thats imported in but will have to be matched to the storage tier and size)
After that Build a diskpart answer file for each server.
Copy each diskpart answer file to each server (match hostnames)
Invoke each diskpart answer file via Invoke-VMscript
Its a very complicated script and it might be more time than its worth, I don't know. I found a script online that is an interactive DiskPart script, its really unfortunate that I cant run it remotely. Any one else run into this? If so please share your experiences working with formatting disks on a large scale.
If you need more info please let me know – I kind of shortened it to avoid a giant post.
by DonJ at 2013-02-01 14:25:44
You could certainly do all of that, and if that's the process you have to complete manually I could certainly see where it could save some time.
In terms of issues running something remotely... it depends. "Remotely" could mean a lot of different things. It's difficult to automate anything that's interactive, though – responding to prompts isn't something PowerShell excels at. An answer file would be the right way to go. And yes, it does seem like a lot of work up front... but what you're doing already seems like a lot of work, so this should help!
I guess the only thing I'd question is the CSV file. If you have to take the time to manually construct that each time, it isn't worth doing a CSV file. It'd be better to just specify that data as input to the command you write. I mean, if you have to type that data, why create an interim file to contain it?
PowerShell Remoting – or better still, workflow, although that's not in v2 – could make this a lot easier and more manageable for you. If it's an option to have that enabled in your standard build, it would open up some nice options – like not having to use Invoke-VMscript, not having to copy the diskpart answer file, and a few other steps could be consolidated into a single command.
by maverick918 at 2013-02-01 16:17:00
Thank you so much for the reply. I've been working through ideas on this for a couple weeks trying to find ways to get this to be easier for our deployment team.
The CSV file is definitely something that could be avoided and I completely agree that its not necessary – Having mandatory parameters to read input from the user based on a given set of information is a brilliant idea. Top notch.
I'm wondering if there is a way to have a given set of information be static on one half of the CLI window and have the user input the set of values based on that static content. Thus the only thing changing is the prompts and not the info each time something is entered by the user.
So what I could do to make the workflow better is this.
Present the user with a list of the disks on the host. In the array presented the tier of storage should be presented.
Ask the user what the Label and Letter for each disk# should be.
Generate the diskpart file based on the user input variables. Save to Disk in a folder created by the script in the users home directory.
The one beef I have with Remoting is that it runs over the network, PowerCLI Guest Operations run straight through VMware Tools at Session 0. It really depends on the work flow of the user, which the host could either already have an IP Address or could still be on an Imaging VLAN which minimal networking is allowed.
This has given new life to this project and I'll be looking at it more in depth this weekend.
By the way I've got your PowerShell In Depth: An administrators guide pre-ordered on Amazon haha! thanks for looking at my issue and responding. I appreciate it!
by poshoholic at 2013-02-04 19:12:03
This sounds quite similar to a project I recently completed myself. If you'd like to discuss what you're doing with me in more detail and compare it with what I've done, I'd be happy to do so. Just fire me a note here and we can work out a mutually convenient time.
You must be logged in to reply to this topic.