Rhala
asked on
PowerShell Script in windows 2012 R2 is not working
Dear All,
i create a new PowerShell script "CreateVM.Ps1" and i run it from PowerShell in windows 2012 R2, the problem is; the first command done, but the remaining is not running, the script to create VHDX, below:
NEW-VHD -Fixed C:\ClusterStorage\Exch-DB1 \Exch-DB1. vhdx -SizeBytes 495GB
NEW-VHD -Fixed C:\ClusterStorage\Exch-DB2 \Exch-DB2. vhdx -SizeBytes 495GB
NEW-VHD -Fixed C:\ClusterStorage\Exch-DB3 \Exch-DB3. vhdx -SizeBytes 495GB
NEW-VHD -Fixed C:\ClusterStorage\Exch-DB4 \Exch-DB4. vhdx -SizeBytes 495GB
NEW-VHD -Fixed C:\ClusterStorage\Exch-DB5 \Exch-DB5. vhdx -SizeBytes 495GB
NEW-VHD -Fixed C:\ClusterStorage\Exch-DB6 \Exch-DB6. vhdx -SizeBytes 495GB
do i have to do anything in between the command above?
i create a new PowerShell script "CreateVM.Ps1" and i run it from PowerShell in windows 2012 R2, the problem is; the first command done, but the remaining is not running, the script to create VHDX, below:
NEW-VHD -Fixed C:\ClusterStorage\Exch-DB1
NEW-VHD -Fixed C:\ClusterStorage\Exch-DB2
NEW-VHD -Fixed C:\ClusterStorage\Exch-DB3
NEW-VHD -Fixed C:\ClusterStorage\Exch-DB4
NEW-VHD -Fixed C:\ClusterStorage\Exch-DB5
NEW-VHD -Fixed C:\ClusterStorage\Exch-DB6
do i have to do anything in between the command above?
hyper-v\NEW-VHD -Fixed C:\ClusterStorage\Exch-DB1\Exch-DB1.vhdx -Size 4GB
hyper-v\NEW-VHD -Fixed C:\ClusterStorage\Exch-DB2\Exch-DB2.vhdx -Size 4GB
hyper-v\NEW-VHD -Fixed C:\ClusterStorage\Exch-DB3\Exch-DB3.vhdx -Size 4GB
hyper-v\NEW-VHD -Fixed C:\ClusterStorage\Exch-DB4\Exch-DB4.vhdx -Size 4GB
hyper-v\NEW-VHD -Fixed C:\ClusterStorage\Exch-DB5\Exch-DB5.vhdx -Size 4GB
hyper-v\NEW-VHD -Fixed C:\ClusterStorage\Exch-DB6\Exch-DB6.vhdx -Size 4GB
I have 2 hyper-v modules so I had to select the right one. Note the Size vs SizeBytes ComputerName : DC01
Path : C:\ClusterStorage\Exch-DB5
VhdFormat : VHDX
VhdType : Fixed
FileSize : 4299161600
Size : 4294967296
MinimumSize :
LogicalSectorSize : 512
PhysicalSectorSize : 4096
BlockSize : 0
ParentPath :
DiskIdentifier : f431105f-e532-40f5-adb8-e9
FragmentationPercentage : 0
Alignment : 1
Attached : False
DiskNumber :
Key :
IsDeleted : False
Number :
ComputerName : DC01
Path : C:\ClusterStorage\Exch-DB6
VhdFormat : VHDX
VhdType : Fixed
FileSize : 4299161600
Size : 4294967296
MinimumSize :
LogicalSectorSize : 512
PhysicalSectorSize : 4096
BlockSize : 0
ParentPath :
DiskIdentifier : 7af9b31c-e119-4157-8a8e-2c
FragmentationPercentage : 0
Alignment : 1
Attached : False
DiskNumber :
Key :
IsDeleted : False
Number :
why not use loops to perform such an action. google "for loop" for powershell
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
i will do that Qlemo and not spend my time doing my paid job. Thanks for reminding me.
Does it work like this:
NEW-VHD -Path C:\ClusterStorage\Exch-DB6
Remember, you can use -Whatif to see what the line does...