• Just a quick update:

    we scheduled this script and explained the dedicated user on-site how to change the drive(s) (one by one).

    this way everything stays the same until the reboot. For some reason, after reboot drives can be assigned to a different controller # but it takes a few secs to modify the script and it's a god to go until the next reboot.  Not perfect but if someone has a better solution (I'm sure that someone has) - welcome.

    Thanks

  • Hi Michael,

    Yes, you right and I’m 100% agree with you but we have what we have …
    Hyper-V server (one), with a receptionist who should change the backup drives (3 of them) on a daily basis. Encryption is not a primary concern for now (for this specific case).
    After receptionist was properly educated everything is mostly fine (85-90%) but I want to get 100% and curious if someone else was able to do it for this specific scenario
    Thanks

  • Hi Michael,

    Yes, I agreed that daily HDD disk swap is not perfect and I don't like it, but in this specific case we are not allowed to send any data outside (so, no remote backup option) and no one wants to spend money on any NAS/SAN, etc..  and the server room in not secure location and client cant/don’t want to use expensive device which someone can just take and walk away. So, the only option we have – a dedicated person who suppose to switch all drives on a daily basis.

    I instructed this (extremely not technical) person to switch ONE drive at the time and in this case, MOSTLY it’s going to the same SCSI controller (in about 75% ) and Remove-VMHardDiskDrive -VMName and  Get-VMScsiController -VMName DC | Add-VMHardDiskDrive works. But I would like to script and forget about it … so, the only constant I have – HDD name and HDD serial#.

    That's why I would like to make a functional scrip and check all connected backup drives and connect to VM based on serial# (or HDD name)

    Again, any alternative working options (not shared drive, not remote backup to an external location, not backup solutions like Veritas) would be highly appreciated

    Thanks

     

  • We have a Hyper-V core with some VM’s on it. Each VM have 3 physical external drive connected to it. VM server on a client-side. The dedicated person supposed to swap all drives daily (MWF, TTS and Monthly) for each VM. So, it's 3 drives per day
    I have a few scripts
    Enter-PSSession vmhost-name
    Remove-VMHardDiskDrive -VMName “server1 name” -ControllerType SCSI -ControllerNumber 0 -ControllerLocation 0
    Remove-VMHardDiskDrive -VMName “server2 name” -ControllerType SCSI -ControllerNumber 0 -ControllerLocation 0
    Get-VMScsiController -VMName “server 1 name” | Add-VMHardDiskDrive -DiskNumber 2
    Get-VMScsiController -VMName “server 2 name” | Add-VMHardDiskDrive -DiskNumber 4
    Get-VM -VMName DC | Get-VMHardDiskDrive

    And it’s working fine for one VM. However, if the person who should swap them miss the cable (it's labelled bu....) or do it wrong drive which should go to for example server 1 actually will to server 2 or opposite. So, it might ok for some time but once a while I have to connect and change controller #

    Goal: write a script which will check all connected backup drives, get their serial numbers and based on the number do connect the drive to one or another VM

    #Connect to VMhost server
    Enter-PSSession vmhost-name
    #remove all existed drives
    Remove-VMHardDiskDrive -VMName “server1 name” -ControllerType SCSI -ControllerNumber 0 -ControllerLocation 0
    Remove-VMHardDiskDrive -VMName “server2 name” -ControllerType SCSI -ControllerNumber 0 -ControllerLocation 0

    #get all connected drives and assign to $Disks and in my case sort by the manufacturer
    $Disks = Get-PhysicalDisk -CanPool $false -Manufacturer Seagate
    or
    $Disks = Get-WMIObject -class win32_PhysicalMedia

    And then I’m lost .. in theory it might be something like
    $SerialNumber = foreach($Disk in $Disks) {IF ($Disk.SerialNumber -eq ' serial number) {[do something here, like connect to VM, maybe: Get-VMScsiController -VMName “server 1 name” | Add-VMHardDiskDrive -DiskNumber 2 }}
    Else
    {check anothr drive}

    In this specific case only 9 drives so it easily can be done by if else

    Again, my original script works fine but it just blindly connects some random drive previously connected to this port to VM and I don’t like it.

    Any suggestions or alternative views will be appreciated.
    PS: yes, I know that I can do NAS as a primary target and backup it after but it’s not my case

    Thanks

  • Dmitrijs G became a registered member 1 month, 2 weeks ago

  • Dmitrijs G's profile was updated 1 month, 2 weeks ago