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.aspx
The final phase is
Step 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
Page 1 of 1
Help with POCSERVER PowerShell Script
#2
Posted 20 May 2012 - 02:26 PM
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?
Though it looks like that is what the are trying todo with the PS_Console.reg import.
Are you running this script as admin?
#3
Posted 20 May 2012 - 02:58 PM
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 $VM
Set-VMMemory -VM $VM 512MB
md C:\VMs\"$VM"
New-VHD -Size 300GB -Path C:\VMs\"$VM"\disk1.vhd
Add-VMDisk -VM $VM -ControllerID 0 -LUN 0 -Path C:\VMs\"$VM"\disk1.vhd
Add-VMDisk -VM $VM -ControllerID 1 -LUN 0 -Path C:\HydrationServers\HydrationServers.iso -DVD
Add-VMNic -VM $VM -Virtualswitch Internal -MAC 00155D000001
$VM = "HYDRATION-DC02"
New-VM -Name $VM
Set-VMMemory -VM $VM 512MB
md C:\VMs\"$VM"
New-VHD -Size 300GB -Path C:\VMs\"$VM"\disk1.vhd
Add-VMDisk -VM $VM -ControllerID 0 -LUN 0 -Path C:\VMs\"$VM"\disk1.vhd
Add-VMDisk -VM $VM -ControllerID 1 -LUN 0 -Path C:\HydrationServers\HydrationServers.iso -DVD
Add-VMNic -VM $VM -Virtualswitch Internal -MAC 00155D000002
$VM = "HYDRATION-MDT01"
New-VM -Name $VM
Set-VMMemory -VM $VM 1024MB
md C:\VMs\"$VM"
New-VHD -Size 300GB -Path C:\VMs\"$VM"\disk1.vhd
Add-VMDisk -VM $VM -ControllerID 0 -LUN 0 -Path C:\VMs\"$VM"\disk1.vhd
Add-VMDisk -VM $VM -ControllerID 1 -LUN 0 -Path C:\HydrationServers\HydrationServers.iso -DVD
Add-VMNic -VM $VM -Virtualswitch Internal -MAC 00155D000003
$VM = "HYDRATION-CM01"
New-VM -Name $VM
Set-VMMemory -VM $VM 1536MB
md C:\VMs\"$VM"
New-VHD -Size 300GB -Path C:\VMs\"$VM"\disk1.vhd
Add-VMDisk -VM $VM -ControllerID 0 -LUN 0 -Path C:\VMs\"$VM"\disk1.vhd
Add-VMDisk -VM $VM -ControllerID 1 -LUN 0 -Path C:\HydrationServers\HydrationServers.iso -DVD
Add-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
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 $VM
Set-VMMemory -VM $VM 512MB
md C:\VMs\"$VM"
New-VHD -Size 300GB -Path C:\VMs\"$VM"\disk1.vhd
Add-VMDisk -VM $VM -ControllerID 0 -LUN 0 -Path C:\VMs\"$VM"\disk1.vhd
Add-VMDisk -VM $VM -ControllerID 1 -LUN 0 -Path C:\HydrationServers\HydrationServers.iso -DVD
Add-VMNic -VM $VM -Virtualswitch Internal -MAC 00155D000001
$VM = "HYDRATION-DC02"
New-VM -Name $VM
Set-VMMemory -VM $VM 512MB
md C:\VMs\"$VM"
New-VHD -Size 300GB -Path C:\VMs\"$VM"\disk1.vhd
Add-VMDisk -VM $VM -ControllerID 0 -LUN 0 -Path C:\VMs\"$VM"\disk1.vhd
Add-VMDisk -VM $VM -ControllerID 1 -LUN 0 -Path C:\HydrationServers\HydrationServers.iso -DVD
Add-VMNic -VM $VM -Virtualswitch Internal -MAC 00155D000002
$VM = "HYDRATION-MDT01"
New-VM -Name $VM
Set-VMMemory -VM $VM 1024MB
md C:\VMs\"$VM"
New-VHD -Size 300GB -Path C:\VMs\"$VM"\disk1.vhd
Add-VMDisk -VM $VM -ControllerID 0 -LUN 0 -Path C:\VMs\"$VM"\disk1.vhd
Add-VMDisk -VM $VM -ControllerID 1 -LUN 0 -Path C:\HydrationServers\HydrationServers.iso -DVD
Add-VMNic -VM $VM -Virtualswitch Internal -MAC 00155D000003
$VM = "HYDRATION-CM01"
New-VM -Name $VM
Set-VMMemory -VM $VM 1536MB
md C:\VMs\"$VM"
New-VHD -Size 300GB -Path C:\VMs\"$VM"\disk1.vhd
Add-VMDisk -VM $VM -ControllerID 0 -LUN 0 -Path C:\VMs\"$VM"\disk1.vhd
Add-VMDisk -VM $VM -ControllerID 1 -LUN 0 -Path C:\HydrationServers\HydrationServers.iso -DVD
Add-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
- ← msgbox in VBScript
- Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
- (SOLVED) sharing violation reading drive c →
Share this topic:
Page 1 of 1



Help

Back to top









