Created
December 21, 2018 14:23
-
-
Save mczerniawski/b3ef3c684d83f78013890169d2d41b23 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#optional | |
#$Creds = Get-Credential #Credki do VM - moga byc domenowe lub lokalne | |
$NewVMDiskProps = @{ | |
VMProps = @{ | |
ComputerName = 'HyperV' | |
VMName = 'VMName1' | |
} | |
VHDProps = @( | |
@{ | |
VHDSize = 100GB | |
VHDType = 'Dynamic' | |
NewFileSystemLabel = 'Data' | |
FileSystem = 'NTFS' | |
}, | |
@{ | |
VHDSize = 150GB | |
VHDType = 'Dynamic' | |
NewFileSystemLabel = 'Data1' | |
FileSystem = 'NTFS' | |
} | |
) | |
OSName = 'OSName1' | |
} | |
foreach ($disk in $NewVMDiskProps.VHDProps) { | |
$addDiskProps = $NewVMDiskProps.VMProps | |
$addDiskProps.VHDSize = $disk.VHDSize | |
$addDiskProps.VHDType = $disk.VHDType | |
if($creds) { | |
$addDiskProps.Credential = $creds | |
} | |
Add-AHVMDisk @addDiskProps -Verbose | |
$formatDriveProps = @{ | |
ComputerName = $NewVMDiskProps.OSName | |
NewFileSystemLabel = $disk.NewFileSystemLabel | |
FileSystem = $disk.FileSystem | |
} | |
if($creds) { | |
$formatDriveProps.Credential = $creds | |
} | |
Format-RemoteDrive @formatDriveProps -Verbose | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment