randalldale Posted May 20, 2012 Posted May 20, 2012 Hello I'm trying to build a POCSERVER (Proof Of Concept Server) from this web site using Windows Server 2008 R2:www.deploymentresearch.com/Blog/tabid/62/EntryId/13/Hydration-Automating-builds-in-your-datacenter.aspxThe final phase isStep 3 – Create and deploy the virtual machines 1.Install the PowerShell Management Library for Hyper-V by running the install.cmd script, ignore any errors about .NET Framework 2.Verify that the files are not having any alternative data streams, if they do, remove it (using explorer or streams from Sysinternals). 3.Create the virtual machines by running the 4_CreateVirtualMachines.ps1 script. Here is the install.cmd script I have to use... and I get unsigned errors in the final phase when trying to run the PS1 files in the last line of this script because the 'ExecutionPolicy' by default is set to 'Restricted'. I can't just open another instance and set to unresricted as this only works for the current running windows so new windows open restricted.@echo off cls echo Installing HyperV Management Library for PowerShell echo ========================================================== echo. echo Ensuring that .Net Framework 2 and Windows PowerShell are installed Echo Press [ctrl][c] to abort or pause dism /online /enable-feature /featurename:NetFx2-ServerCore dism /online /enable-feature /featurename:MicrosoftWindowsPowerShell echo. echo About to create folder and copy Powershell module. Echo Press [ctrl][c] to abort or pause md "%ProgramFiles%\modules\HyperV" copy %0\..\HyperV_install\*.* "%ProgramFiles%\modules\HyperV" echo. echo About to set registry entries for PowerShell script execution, module path and console settings Echo Press [ctrl][c] to abort or pause start /D %0\.. /w regedit "PS_Console.REG" echo. echo About to Launch PowerShell Echo Press [ctrl][c] to abort or pause start %windir%\System32\WindowsPowerShell\v1.0\powershell.exe -noExit -Command "Import-Module '%ProgramFiles%\modules\Hyperv' "***I know I need to instert the "Set-ExecutionPolicy Unrestricted or -ExecutionPolicy Unrestricted " or something like this somewhere in the last line but everywhere I do I just get different errors.I'm hoping that this is simple enough that someone sees the issue right away as I was hoping to not have to go out and learn PS too quickly just to make this script work.Thanks,RD
IcemanND Posted May 20, 2012 Posted May 20, 2012 You could change the executionplocy for the machine by opening powershell as admin and setting the policy.Though it looks like that is what the are trying todo with the PS_Console.reg import.Are you running this script as admin?
randalldale Posted May 20, 2012 Author Posted May 20, 2012 Actually looks like I got this part fixed. It seems when you copy a script over from another computer, i.e. the zip file, LocalMachine sets the content to BLOCK so I went into all the PS files properties I was importing and changed them to UNBLOCK. Seems to have ran no problem.Now I'm getting nothing but errors on the next script ,4_CreateVirtualMachines.ps1, that is supposed to create the VHD files.*****Import-Module 'C:\Program Files\modules\HyperV\HyperV.psd1'#New-VMInternalSwitch "Internal"$VM = "HYDRATION-DC01"New-VM -Name $VMSet-VMMemory -VM $VM 512MBmd C:\VMs\"$VM"New-VHD -Size 300GB -Path C:\VMs\"$VM"\disk1.vhdAdd-VMDisk -VM $VM -ControllerID 0 -LUN 0 -Path C:\VMs\"$VM"\disk1.vhdAdd-VMDisk -VM $VM -ControllerID 1 -LUN 0 -Path C:\HydrationServers\HydrationServers.iso -DVDAdd-VMNic -VM $VM -Virtualswitch Internal -MAC 00155D000001$VM = "HYDRATION-DC02"New-VM -Name $VMSet-VMMemory -VM $VM 512MBmd C:\VMs\"$VM"New-VHD -Size 300GB -Path C:\VMs\"$VM"\disk1.vhdAdd-VMDisk -VM $VM -ControllerID 0 -LUN 0 -Path C:\VMs\"$VM"\disk1.vhdAdd-VMDisk -VM $VM -ControllerID 1 -LUN 0 -Path C:\HydrationServers\HydrationServers.iso -DVDAdd-VMNic -VM $VM -Virtualswitch Internal -MAC 00155D000002$VM = "HYDRATION-MDT01"New-VM -Name $VMSet-VMMemory -VM $VM 1024MBmd C:\VMs\"$VM"New-VHD -Size 300GB -Path C:\VMs\"$VM"\disk1.vhdAdd-VMDisk -VM $VM -ControllerID 0 -LUN 0 -Path C:\VMs\"$VM"\disk1.vhdAdd-VMDisk -VM $VM -ControllerID 1 -LUN 0 -Path C:\HydrationServers\HydrationServers.iso -DVDAdd-VMNic -VM $VM -Virtualswitch Internal -MAC 00155D000003$VM = "HYDRATION-CM01"New-VM -Name $VMSet-VMMemory -VM $VM 1536MBmd C:\VMs\"$VM"New-VHD -Size 300GB -Path C:\VMs\"$VM"\disk1.vhdAdd-VMDisk -VM $VM -ControllerID 0 -LUN 0 -Path C:\VMs\"$VM"\disk1.vhdAdd-VMDisk -VM $VM -ControllerID 1 -LUN 0 -Path C:\HydrationServers\HydrationServers.iso -DVDAdd-VMNic -VM $VM -Virtualswitch Internal -MAC 00155D000004*****For now I will go back and recreate all the steps to see if I missed anything.Consider this item closed.Thanks for the help,RD
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now