Exemplo n.º 1
0
        public static Collection <PSObject> CreateVirtualHardDisk(PowerShellManager powerShellwithJobs, string destinationPath, VirtualHardDiskType diskType, uint blockSizeBytes, UInt64 sizeGB, string serverNameSettings)
        {
            string destFolder = Path.GetDirectoryName(destinationPath);

            if (!DirectoryExists(destFolder, serverNameSettings))
            {
                CreateFolder(destFolder, serverNameSettings);
            }

            destinationPath = FileUtils.EvaluateSystemVariables(destinationPath);

            Command cmd = new Command("New-VHD");

            cmd.Parameters.Add("SizeBytes", sizeGB * Constants.Size1G);
            cmd.Parameters.Add("Path", destinationPath);
            cmd.Parameters.Add(diskType.ToString());
            if (blockSizeBytes > 0)
            {
                cmd.Parameters.Add("BlockSizeBytes", blockSizeBytes);
            }
            return(powerShellwithJobs.TryExecuteAsJob(cmd, true));
        }