System Center Orchestrator: "Modify VM Disk" activity from the VMware vSphere IP

Valentin Nedeianu 0 Reputation points
2025-01-30T06:56:19.5933333+00:00

Hello,

I am trying to implement an automatic disk increase for a VMware machine using a SCORCH runbook; one of the activities from the VMware vSphere integration pack looks like could do the job: "Modify VM Disk". Unfortunately, there is a required field named "SCSI Unit Key" in the properties of the activity that I couldn't find information about and don't know what should contain or where to get that information from.

If you used this activity, I would appreciate some hints.

Thank you!

System Center Orchestrator
System Center Orchestrator
A family of System Center products that provide an automation platform for orchestrating and integrating both Microsoft and non-Microsoft IT tools.
252 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. XinGuo-MSFT 21,751 Reputation points
    2025-01-31T08:33:18.26+00:00

    Hi,

    To find the SCSI Unit Key for a virtual disk in VMware vSphere, follow these steps:

    1. Open the vSphere Client and navigate to the virtual machine.
    2. Select the VM and go to the "Edit Settings" option.
    3. In the "Virtual Hardware" tab, locate the virtual disk you want to modify.
    4. The SCSI ID (which includes the SCSI Unit Key) will be displayed in the "Virtual Device Node" section.

  2. XinGuo-MSFT 21,751 Reputation points
    2025-02-05T02:33:56.2+00:00

    Hi,

    Please attempt to retrieve the SCSI Unit Key within the guest operating system.

    User's image


  3. Jon Royer 0 Reputation points
    2025-03-12T14:01:48.96+00:00

    I figured I would share this since it may save somebody in the future. :) This took me a solid week of work to figure out and put into SCORCH. It's not pretty but it saves me a ton of calls at night. I do have controls in place to make sure it does not expand more then a few times before calling me.

    • I have two .Net Activity Modules running PowerShell with a Compare Values to make sure the SCSI IDs match.
    • Frist script below pulls the SCSI ID from the Windows Machine.
    • Second Script pulls SCSI ID from VMware to check it.
    • I use the Compare Values to make sure they match before moving to the expand disk.

    Hope this helps!

    
    $z = Invoke-Command -ComputerName <ServerThatNeedsMoreRoom> -ScriptBlock { 
    
    ### Incoming From SCORCH ####
    $computerName = "<ServerThatNeedsMoreRoom>"
    $driveLetter = "D"
    $winDriveLetter = "$($driveLetter):"
    #########
    
    # Getting Disk Info from Windows Server
    $LogicalDisk = Get-WmiObject -Class Win32_LogicalDisk | Where-Object {$_.DeviceID -like $winDriveLetter}
    $Win32_LogicalDiskToPartition = Get-WmiObject -Class Win32_LogicalDiskToPartition
    $Win32_DiskDriveToDiskPartition = Get-WmiObject -Class Win32_DiskDriveToDiskPartition
    $Win32_DiskDrive = Get-WmiObject -Class Win32_DiskDrive 
    $LogicalDiskToPartition = $Win32_LogicalDiskToPartition | Where-Object {$_.Dependent -eq $LogicalDisk.Path}
    $DiskDriveToDiskPartition = $Win32_DiskDriveToDiskPartition | Where-Object {$_.Dependent -eq $LogicalDiskToPartition.Antecedent}
    $DiskDrive = $Win32_DiskDrive | Where-Object {$_.__Path -eq $DiskDriveToDiskPartition.Antecedent}
    
    ### For Troubleshooting ####
    write-host "Testing" 
    $ts1 =  $DiskDriveToDiskPartition.Antecedent
    $ts2 =  $DiskDrive
    
    #### Export out of Invoke ####
        [PSCustomObject]@{                                    
        'Computer' = $computerName
        'DeviceID' = $LogicalDisk.DeviceID
        'SCSIBus' = $DiskDrive.SCSIBus
        'SCSIPort' = $DiskDrive.SCSIPort
        'SCSITargetId' = $DiskDrive.SCSITargetId
        'SCSILogicalUnit' = $DiskDrive.SCSILogicalUnit
        'ts1' = $ts1
        'ts2' = $ts2
            }
        }
    
    # **** Output Here *****" # 
    $z.Computer
    $SCSIIINFO = "$($z.SCSIBus.ToString()):$($z.SCSITargetId.ToString())"
    
    #write-host "**** Internal Check *****" 
    #write-host $z.ts1
    #write-host $z.ts2
    #write-host " " 
    #write-host $z.DeviceID
    
    
    ## Incoming from SCORCH ####
    $WSCSI = "<Carry Over SCSI ID from the Get Windows SCSI ID>"
    $computerName = "<VM Name>"
    
    
    Connect-VIServer –Server VCenterServer -username username1 -Password Password1 -SaveCredentials
    $diskInfo= @()
    $VMView = Get-VM $computerName | Get-View
    foreach ($VirtualSCSIController in ($VMView.Config.Hardware.Device | Where-Object {$_.DeviceInfo.Label -match "SCSI Controller"}))
    
    {
        foreach ($virtualDiskDevice in ($VMView.Config.Hardware.Device | Where-Object {$_.ControllerKey -eq $VirtualSCSIController.Key})) 
        {
            $virtualDisk = "" | Select-Object VMname, SCSIController, DiskName, SCSI_ID, DiskFile, DiskSize
            $virtualDisk.VMname = $VMview.Name
            $virtualDisk.SCSIController = $VirtualSCSIController.DeviceInfo.Label
            $virtualDisk.DiskName = $virtualDiskDevice.DeviceInfo.Label
            $virtualDisk.SCSI_ID = "$($VirtualSCSIController.BusNumber.ToString()):$($virtualDiskDevice.UnitNumber.ToString())"
            $virtualDisk.DiskFile = $virtualDiskDevice.Backing.FileName
            $virtualDisk.DiskSize = $virtualDiskDevice.CapacityInKB * 1KB / 1GB
            
            if ($virtualDisk.SCSI_ID -eq $WSCSI) {
                $disk_SCSI = $virtualDisk.SCSI_ID
                $disk_Name = $virtualDiskDevice.DeviceInfo.Label
                $disk_size = $virtualDisk.DiskSize
    
            }
        }
    }
    
    Disconnect-VIServer -Server VCenterServer -Force -Confirm:$false
    
    $disk_SCSI
    $disk_Name
    $disk_size
    

    enter image description here

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.