I'm trying to create a script that will split on various object. For example I have disks name
vm01-disk1
vm01_disk2
I'm trying to split the disk names so I can rename the disk vm, but retain the disk number, what I've tried is
$snapshot = Get-AzSnapShot
$vhdlong = ($snapshot.name).Split("_")[0]
$vhdrename = $vhdlong.split("-")[1]
But this still leaves vm01_disk2 untouched, if I add $vhdrename = $vhdlong.split("_")[1]
it leaves vm01-disk1 untouched.
Hope that makes sense. Thanks in advance for any tips or advice :)