Is it possible to run "shrink" using PowerCLI VMtools

Hi all

Is it possible to run the VMware Tools "shrink" using PowerCLI function? WMI is not desirable since it would need to open ports in the firewall that are not open at the moment, I'm looking for a solution where it could be done directly from vCenter Server as upgrade VMware Tools to remove CD/DVD.

I gave a "base" intro on _task methods using in How to display and monitor running tasks?. "

Taking into account the Yavor comments that the skeleton code becomes:

......
$taskMoRef = $esx.ExitMaintenanceMode_Task(0)

$task = Get-View $taskMoRef
while ($task.Info.State -eq "running" -or $task.Info.State -eq "queued") {
  sleep 2
  $task.UpdateViewData("Info.State")
}
# Check return code of the _task in $task.Info.result
if($task.Info.result -ne "success"){
   ....
}
...

For this task (ShrinkVirtualDisk_Task), you must make some preparations before the actual call.

The _this parameter you indicates which object, you can call the method. In this method, it is the VirtualDiskManager.

You can get to the the ServiceInstance VirtualDiskManager.

$vdiskMgr = Get-View -Id (Get-View ServiceInstance).content.virtualDiskManager

Then, you need to set the parameters for the method.

$name = "[datastore1] PC1/PC1.vmdk"
$dcMoref = (Get-Datacenter "dc1" | Get-View).MoRef
$copy = $false

Now you have all the elements to make the call

$taskMoRef = $vdiskMgr.ShrinkVirtualDisk_Task($name,$dcMoRef,$copy)

Bring together

$vdiskMgr = Get-View -Id (Get-View ServiceInstance).content.virtualDiskManager
$name = "[datastore1] PC1/PC1.vmdk"
$dcMoref = (Get-Datacenter "dc1" | Get-View).MoRef
$copy = $false
$taskMoRef = $vdiskMgr.ShrinkVirtualDisk_Task($name,$dcMoRef,$copy)
$task = Get-View $taskMoRef
while ($task.Info.State -eq "running" -or $task.Info.State -eq "queued") {
  sleep 2
  $task.UpdateViewData("Info.State")
}
# Check return code of the _task in $task.Info.result
if($task.Info.result -ne "success"){
   ....
}

Hope this has helped.

Tags: VMware

Similar Questions

  • is equivalent of LabVIEW player - possible to run a vi on a computer without complete labview installed using free software?

    Hello

    Neither affirm that labview player is no longer exist, is there an alternative that will allow finishes vi to run by using the pc without the complete installation of labview.

    I have a full version of labview 2010 on my laptop using one of 5 licenses available at my place of work. All 5 licenses are now being taken, but I would like to run finished vi on other laptops. Surely, I need not to buy another copy of labview or more licenses to run VI finished, requiring no modification.

    Thank you

    Andy

    Is it not the exe file generator included in complete Labview?

  • Is it possible to interact with the guest virtual computer console using PowerCLI?

    I'm trying to automate the installation of Linux on the ESXi systems.  Installing Linux is all from the command line.  Is there a way that I can interact with the console or shell comments VM using PowerCLI?

    In my view, customization works only with officially listed linux distributions.

    Kind regards

    Nedko Nedev

    PowerCLI development team

  • Get a user/group, details of role using Powercli

    Hi all

    I wrote the script to extract the user role by using Powercli below information and got the details.

    $Excel = new-Object - ComObject Excel.Application

    $Excel.visible = $True

    $Excel = $Excel.Workbooks.Add)

    $Sheet = $Excel.Worksheets.Item (1)

    $Sheet.Activate () | Out-Null

    $Sheet.Name = 'vCenter roles. "

    $Sheet.Cells.Item (1,1) = 'name '.

    $Sheet.Cells.Item (1,2) = 'Role '.

    $Sheet.Cells.Item (1,3) = "entity".

    $Sheet.Cells.Item (1.4) = 'entity Type.

    $Sheet.Cells.Item (1.5) = 'vCenter.

    $intRow = 2

    $WorkBook = $Sheet.UsedRange

    $WorkBook.Interior.ColorIndex = 19

    $WorkBook.Font.ColorIndex = 11

    $WorkBook.Font.Bold = $True

    $gps = get-vipermission

    {foreach ($gp to $gps)

    $vc = $gp.uid.split(':@') [1]

    $Sheet.Cells.Item ($intRow, 1) = $gp.principal

    $Sheet.Cells.Item ($intRow, 2) = $gp. Role

    $Sheet.Cells.Item ($intRow, 3) = $gp.entity.Name

    $Sheet.Cells.Item ($intRow, 4) = $gp.entityid.split('-') [0]

    $Sheet.Cells.Item ($intRow, 5) = $vc

    $intRow = $intRow + 1

    }

    $WorkBook.EntireColumn.AutoFit)

    In addition, I am trying to expand the list of privileges using the script below.

    $gvips = get-vipermission | Role of group | Select name

    {foreach ($gvip to $gvips)

    Get-ferrule-name $gvip.name | Select Name, PrivilegeList

    }

    I can find out the name and the list of privileges, but not completely due to the long list of Privlieges for certain roles. I'm out like {xxx.xxxxxxxxxxxxxxxx...}

    As it then not be able to see full privileges.

    If single role that I want to see, then I can run the command get-ferrule-name admin | Select - expandproperty PrivilegeList

    Above command will list the perfect performance. But this command cannot be used for loop with the parameter 'Name '.

    Can anyone suggest me how to get result with all the details.

    Is it possible I can get 2 out of Scripts in a spreadsheet or HTML with SameFormat file.

    Thanks in advance.

    Try like this

    $reportName = "C:\Report.xlsx".

    Get-VIPermission |

    Select Principal,Role,@{n='Entity'; E={$_. Type of Entity.Name}},@{N='Entity'; E={$_. "EntityId.Split('-') [0]}}, @{N = 'vCenter';" E={$_. {{Uid.Split (' @: ') [1]}} |

    Export-Xlsx-path $reportName - WorksheetName permissions

    Get-ferrule.

    Select Name,@{N='PrivilegeList'; E = {[string]: join (",", $_.)} PrivilegeList)}} |

    Export-Xlsx-path $reportName - AppendWorksheet - WorksheetName roles - end SheetPosition

  • Is it possible to run Windows 7 on Tecra S1 PT831E

    Hello

    is it possible to run Windows 7 on my Tecra S1 PT831E 126PQ?

    I've updated the BIOS (last?) version 2.50 (it should be suitable also for Windows 7). With this done BIOS is fully compliant with ACPI?

    Checking with Windows 7 Upgrade Advisor should not be a problem, in fact.

    Thanks for any help.

    Well cordially

    ThomasMuentzer

    Hello

    Of course, you can install Windows 7 on your good old classic.
    But the fact is that there is no official driver Win 7 on the page of the European driver Toshiba, it seems that you have to collect the pilots in his own hand.

    But in general this should not be a problem of submission.
    WLAN, LAN drivers can be downloaded from the pages of chip manufacturer driver touchpad can be used in other models of computers, laptops and Toshiba as VAP (value added package) Flash cards tools or similar

  • Is it possible to run virtual machines on Satellite A500-1DN?

    I want to know its possible to run a virtual machine on my laptop?

    (Windows VM cannot start the computer does not support hardware virtualization ed)

    Help please

    Even if the processor supports virtualization, it can be disabled in the BIOS by default and must be activated before use.
    Then please enter advanced BIOS settings and check if the virtualization technology is enabled or disabled.

  • Is it possible to run splitview with two-mode applications landscape on iPad pro in portrait mode?

    Hello

    Is it possible to run splitview so that both applications are in landscape mode, while now the iPad in portrait mode?

    So basically, instead of apps side by side, it would be top apps down.

    I use goodreader to watch a video while surfing the web on safari. But when he was knocked down by side there are a lot of realestate lost on the side of the video.

    see you soon

    Unfortunately not. If I was a Pro too much it would be my favorite. Try using the comments link to suggest to Apple.

    http://www.Apple.com/feedback/

  • Is it possible to run DiagOnCAN with the NI-CAN driver only (without car Diag command Set)

    Hello world

    Is it possible to run DiagOnCan without using Diag command set auto - only with the NI-CAN driver (hardware I use is low tolerant speed - USB8472 and NOR-XNET)?

    G. Petko

    no problem to do with your hardware and NI-CAN frame API.

    However, you must implement the Diag and Services Transport layer on your own, which is quite a big job.

    I recommend you spend the money for automotive diagnostic command set that supports

    • NI CAN (PXI, PCI, PCMCIA, USB)

    • NOR-XNET

    • cRIO/985 x target (Pharlap and VxWorks) #.

    which means that if you plan to transfer your application in the future to different hardware target or the real-time target, that you don't need to change your app at all.

  • There is a possibility to run Labview projects or to set them off from a batch file or if the exist and the ability to control labview or run it from an external application?

    Hi, I m a bit new in LabVIEW and I'd like to ask a few questions...

    -There is a possibility to run Labview projects or to set them off from a batch file or if the exist and the ability to control labview or run it from an external application?

    -One API PI or raspberry beaglebone exists for LabVIEW?

    -Power supply Wich can recommend you control with LabVIEW? (some chip solution witn 0 - 30v / 0 - 3A DC)

    Thank you very much for your advice!

    Best regards

    Elena

    Elena,

    I know raspberry, so no comment on that.

    For the rest:

    -Do you want to create tools for developers? If so, we must look in the API of project VI and VI server. If this isn't the case, please compile your application LV as executable and call this one using a batch file.

    -LV prefer specific supplies. LV is a programming language. There are several power supply providers (including OR) which provide directly the LV API for their power supplies. So, essentially, the approach is:

    1. choose food that serves your needs.

    2. check if the power supply has a standard interface for programming (such as Ethernet, GPIB, or if the power supply is PXI, is already providing a programming interface!)

    3. check if the LV API (so-called "instrument driver") is available for the device. In the case of a PXI system, get you a device driver (for example NI DCPower).

    4. check if the LV samples are available (for example in the Finder for example LV once you have installed the driver).

    Norbert

  • Is it possible to run a 3rd monitor in my Pavilion dv8t

    Is it possible to run a 3rd monitor in my Pavilion dv8t

    Hey gogydog,

    You can have a maximum of 3 displays with this unit (depending on your configuration): a connected to HDMI, a connected VGA and LCD integrated Notepad. So, 2 external and 1 integrated display. It is not possible to connect 3 external displays, unless you use a third party (such as Matrox DualHead) material, however the quality/compatibility is not guaranteed.

  • is it possible to run both systems, such as windows xp & windows 8 on a pc

    is it possible to run both systems, such as windows xp and windows 8 on a pc at the same time

    Hi Susan,.

    Actually run two at the same time?  N ° having two installed so that you can choose which you want to run?  Yes (as long as your computer can accommodate two operating systems and has appropriate and such pilots and you will understand the compatibility requirements and other rules for software application).

    How to do this depends on which two average you and your hardware (you could partition the disk to dual-boot, use readers separate for dual boot or create a similar to a dual-boot configuration, if the two you choose cannot work together in a normal dual-boot or use a Virtual Machine installed on an operating system to install and run the other OS and so on).  Certain combinations will be much easier than others.

    So the answer is it is theoretically possible to have two (or three or more) installed, but not running at the same time - but I guess it could be argued that a Virtual Machine means in fact the two BONES are technically running - but that's just the way it seems to me since you can use only one at a time) , but may not work in your specific situation depending on your computer hardware and bios, the software you use, which specifies the operating systems you want to be able to access separately and so on.  To do this, we need information much more to offer help.

    I hope this helps.

    Good luck!

    Kosh

  • Using PowerCLI to recover the capacity of volume comments data

    I am using PowerCLI to declare on the volume letter and free space associated with a guest computer.  I am currently addressing this problem through the extensiondata of the VM guest and then placing the properties I want in a PSObject.

    The question that I am running is that numeric values keep coming up as zero when it is inside the loop for, although they correctly resolve by themselves.  One thing I found interesting was these two upcoming properties like "System.Nullable [long"] when executing GetType(), but I don't know if that is related to the question.

    The script is below, and I changed the font color on the problem section.  I'd appreciate any help.

    # Pre - performance Variables

    $USCulture = New-Object - TypeName System.Globalization.CultureInfo - ArgumentList "en - us".

    $USCulture.NumberFormat.PercentDecimalDigits = 2

    $USCulture.NumberFormat.NumberDecimalDigits = 2

    Guest computers #Get

    [table] $vmguests = $vmcluster | Get - VM

    foreach ($vmguest to $vmguests)

    {

    $vmguestinfo = new-Object - TypeName System.Management.Automation.PSObject

    $vmguestinfo | Add-Member - MemberType NoteProperty-Name "Hostname" - value $vmguest.extensiondata.guest.Hostname

    $vmguestinfo | Add-Member - MemberType NoteProperty-Name "GuestState"-$vmguest.extensiondata.guest.GuestState value

    $vmguestinfo | Add-Member - MemberType NoteProperty-Name 'GuestFullName'-$vmguest.extensiondata.guest.GuestFullName value

    $vmguesthdds = $vmguest. ExtensionData.Guest.Disk

    for ($i = 0; $i - lt $vmguesthdds. Length; $i++)

    {

    $vmguestinfo | Add-Member - MemberType NoteProperty-Name ' DiskPath$ I '-$vmguesthdds [$i] value. DiskPath

    $vmguestinfo | Add-Member - MemberType ScriptProperty-Name ' CapacityGB$ I "-value {($vmguesthdds [$i]. Capacity). ToString ("N", $USCulture)}

    $vmguestinfo | Add-Member - MemberType ScriptProperty-Name ' UsedSpaceGB$ I "-value {[System.Decimal]: Subtract ($vmguesthdds [$i].} Capacity, $vmguesthdds [$i]. FreeSpace). ToString ("N", $USCulture)}

    $vmguestinfo | Add-Member - MemberType ScriptProperty-Name ' FreeSpacePercent$ I "-value {[System.Decimal]: Divide ($vmguesthdds [$i].} FreeSpace), ($vmguesthdds [$i]. Capacity). ToString ("P", $USCulture)}

    }

    [table] $vmguestresults += $vmguestinfo

    }

    Thank you

    Yes, he had a few typos in the code.

    I corrected which, in the code and the attachment.

    Try this one.

    I'm afraid that I can't achieve this GitHub repository.

    A search on your GitHub account does not return either

  • check if there is a service on a vmguest using powercli

    Is there a way I can check if there is a service on a vmguest, using powercli?

    I found several ways to do it using powershell commands, but I want to know if I can do it using powercli.

    Thank you

    If you have installed on the virtual machines VMware tools, you can use the Invoke-VMScript cmdlet to run a script PowerShell inside the guest OS.

    $vm = get-VM-name MyVM

    $cmd = "get-Service WinRM name.

    Invoke-VMScript - VM $vm - $cmd ScriptText

    According to the account under which you run the script, you may need to use the GuestCredential parameter

  • is it possible to run ExtensionData.UpdateServerData (asynchroniously)?

    is it possible to run ExtensionData.UpdateServerData (asynchroniously)? I found very useful script that allows to changin VM storage profile. The only issue I have with it is that it runs a ExtensionData.UpdateServerData () to the date and time of execution could be considerably shortened if these tasks can be performed in parallel.

    It depends on if the async method is mapped in the framework.

    These methods are usually mapped 2 perfumes: $vm. ExtensionData. UpdateServerData (sync) and $vm. ExtensionData. UpdateServerData_Task (async).

    You can check with Get-Member, at $vm. ExtensionData, methods that are available through the .net object.

  • Using PowerCLI update CMDB

    I need a guide on how to use PowerCLI to update my CMDB.  For example:

    -J' I create a Virtual Machine in vCenter

    CMDB - one yet knows about this

    -J' have the VMname, IP address, OS vCenter with powerCLI type (this part is easy)

    Then I go and use the same script to hit the API of a commonly used CMDB and update the CMDB.

    Is there a guide for general how to do this or a script example of someone who did it?

    Thank you!

    For example, I use a simple real method:

    Every night a script is on demand making it an export of the vCenters with relevant information, CPU, memory, StorageSpace, etc. VMname.

    It is exported to a CSV file to a shared location.

    Every night he runs a CMDB solution, importing the CSV file and editing the right values. I don't know the name of solutions. Try to understand how you can modify / add CMDB items in your first CMDB software, from there you can begin to build your script to get the relevant information in the right format so your CMDB can add it.

Maybe you are looking for