Array Setup and Networking
1752866 Members
3842 Online
108791 Solutions
New Discussion юеВ

Re: Powershell - create clone, mount clone

 
SOLVED
Go to solution
jliu79
Frequent Advisor

Re: Powershell - create clone, mount clone

I did try the import command and hereтАЩs what I got:

Import-Module : Could not load file or assembly

'file:///C:\Users\admin\Documents\WindowsPowerShell\Modules\nimble\GroupMgmt.dll' or one of its dependencies. Operation

is not supported. (Exception from HRESULT: 0x80131515)

At line:1 char:1

+ Import-Module nimble

+ ~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: ( , FileLoadException

    + FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand

jrich52352
Trusted Contributor

Re: Powershell - create clone, mount clone

this is from the Win8 box?

if you type in $host what do you get? It should say its V3. if its V2 then its possible that the groupmgmt.dll might be compiled for .net 4.0 and since powershell V2 is .net 2.0 that might cause an issue.

also did you unblock the files? that might also cause it

you can do, in V3

gci "$(split-path $profile)\modules\nimble" -r | Unblock-File

jliu79
Frequent Advisor

Re: Powershell - create clone, mount clone

That was on a Windows server 2012 datacenter which has version 3. I confirmed it by running get-host command. The files have been unblocked too.

jliu79
Frequent Advisor

Re: Powershell - create clone, mount clone

One thing I noticed is you said groupmgmt.dll might be compiled for .net 4.0 but I only have 4.5 on my Windows 8 and Windows server 2012. That might causing the issue?

jrich52352
Trusted Contributor

Re: Powershell - create clone, mount clone

try doing this, go to the folder that contains the files (nimble folder) and type this

add-type -Path .\GroupMgmt.dll

also, im not sure if this matters,but do you run it elevated? i have mine set to by default.

jliu79
Frequent Advisor

Re: Powershell - create clone, mount clone

Thanks Justin. Running add-type command fixed the problem.

jrich52352
Trusted Contributor

Re: Powershell - create clone, mount clone

Thats kind of odd since essentially thats what the import-module is doing.

smilerspeaking136
Occasional Contributor

Re: Powershell - create clone, mount clone

I did stumble across this yesterday - after getting wound up using disk part, new PS modules should be able to cover the requirements for disk part when mounting a clone.

http://swodniw.wordpress.com/2012/10/12/powershell-cmdlets-one-by-one-or-how-to-replace-diskpart-with-powershell/

I'll be looking into this in a week or so.

jrich52352
Trusted Contributor

Re: Powershell - create clone, mount clone

yeah 2012 is awesome with its cmdlets... we're making a push to get to 2012 for this reason. however you can feed stuff to diskpart fairly easily..

$id = gwmi win32_diskdrive -ComputerName $ComputerName -Credential $Credential -Filter "model LIKE 'vmware%'" | sort @{e={(($_.size /1gb) / $size)%1}},index -Descending |select -first 1 -exp index

$dpscript = @"

select disk $id

online disk noerr

convert gpt noerr

create partition primary noerr

assign letter=$letter

FORMAT FS=NTFS UNIT=64k QUICK Label=SQL

"@

$job = Invoke-Command -ScriptBlock {$args[0] | diskpart} -Session $session -ArgumentList $dpscript

I use this as part of my Add-DriveToVm

smilerspeaking136
Occasional Contributor

Re: Powershell - create clone, mount clone

I've just got the following to work - (Remove "write-host" from the "foreach" line **or leave in to see what its going to do **):

### get Nimble disks ###

$nimbledisks = get-disk | Where {$_.Manufacturer -like "Nimble*"} | select -expandproperty "number"

### Remove readonly ###

write-host "remove readonly atribute from disks > $nimbledisks" -foregroundcolor yellow

foreach( $disk in $nimbledisks ){ write-host set-disk -number $disk -isreadonly 0}

write-host "Disks > $nimbledisks -> writeable" -foregroundcolor green

### Remove offline ###

write-host "remove offline atribute from disks > $nimbledisks"  -foregroundcolor yellow

foreach( $disk in $nimbledisks ){ write-host set-disk -number $disk -isoffline 0}

write-host "Disks > $nimbledisks -> online" -foregroundcolor green

onlinedisks.PNG.png

Next I need to work out assigning drive letters, holiday first though