- # Configure-DC1-1.ps1
- # Converts Server to DC
- # Version 1.0.0 - 14 Jan 2013
- # See http://tfl09.blogspot.com for more details
- # Config script block
- $conf = {
- # Install the AD - the reboot is or should be automagic
- Install-Windowsfeature AD-Domain-Services -IncludeManagementTools
- # Now install the AD to DC1
- $PasswordSS = ConvertTo-SecureString -string 'Pa$$w0rd' -AsPlainText -Force
- Install-ADDSForest -DomainName Reskit.Org -SafeModeAdministratorPassword $PasswordSS -force -InstallDNS -DomainMode Win2012 -ForestMode Win2012
- }
- # Here is start of script
- $Username = "DC1\administrator"
- $PasswordSS = ConvertTo-SecureString 'Pa$$w0rd' -AsPlainText -Force
- $Creddc1 = New-Object system.management.Automation.PSCredential $username,$PasswordSS
- # First, run a simple script block to check that the server is actually running and is the one we think it is
- Invoke-Command -ComputerName DC1 -ScriptBlock { ipconfig;hostname} -Credential $Creddc1 -verbose
- Pause
- # Now add create our forest/domain/dc
- Invoke-Command -ComputerName DC1 -Scriptblock $conf -Credential $Creddc1 -verbose
This blog contains PowerShell scripts, more PowerShell scripts and still more PowerShell scripts. Occasionally you may see some organisational posts.
Showing posts with label Hyper-V. Show all posts
Showing posts with label Hyper-V. Show all posts
Wednesday, 23 January 2013
Configure-DC1-1.ps1
Labels:
deployment scripts,
Hyper-V,
powershell,
PowerShell scripts
Sunday, 16 September 2012
Set-HyperVHostDefault.ps1
- <#
- .SYNOPSIS
- This script demonstrates setting default values for Local Hyper-V host.
- .DESCRIPTION
- This script imports the Hyper-V module then uses it
- to set certain default values for this hyper-V Host
- .NOTES
- File Name : Set-HyperVHostDefault.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 3.0 and Windows 8/Server 2012
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- .EXAMPLE
- Left as an exercise for the reader
- #>
- # Import Hyper-V Module
- Import-Module Hyper-V
- Write-Verbose "$((gcm -module hyper-v).Count) cmdlets imported in Hyper-V Module"
- # Create $parm hash table!
- $parm = @{}
- # Specify the Computername
- $parm += @{ComputerName = "Win8.Cookham.Net"}
- # Specify the Hard Disk Path
- $parm += @{VirtualMachinePath = "E:\hyperv"}
- # Specify the VHD Disk Path
- $parm += @{VirtualHardDiskPath = "E:\hyperv"}
- # Set the VM host accordingly
- Write-Verbose "Setting parameters as follows:";$parm
- Set-VmHost @parm
- # And Display Details
- Get-VMHost
- # End Set-HyperVHostDefaults
New-InternalSwitch.ps1
- <#
- .SYNOPSIS
- This script demonstrates creating a Hyper-V Switch
- .DESCRIPTION
- This script imports the Hyper-V module then uses it
- to create an Internal Switch for use in future provisioning.
- .NOTES
- File Name : New-InternalSwitch.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 3.0 and Windows 8/Server 2012
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- .EXAMPLE
- C:\foo\> .New-InternalSwitch.ps1
- VERBOSE: New-InternalSwitch will create a new virtual network.
- Name SwitchType NetAdapterInterfaceDescription
- ---- ---------- ------------------------------
- Internal Internal
- #>
- # Import Hyper-V Module
- Import-Module Hyper-V
- Try {New-VMSwitch -Name Internal -SwitchType Internal -ComputerName LocalHost -Verbose}
- Catch { "Failed to create switch"; $error[0] }
- # End New-InternalSwitch.ps1
Saturday, 9 January 2010
Get-VMMemory
- <#
- .SYNOPSIS
- This script displays the virtual Memory assigned to Hyper-V
- VMs on a given host.
- .DESCRIPTION
- This script uses The Hyper-V module from Codeplex to first
- get all the VMs on a given server, then display the memory
- allocated to each VM.
- .NOTES
- File Name : get-VMMemory.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- and HyperV module from Codeplex
- http://pshyperv.codeplex.com
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- .EXAMPLE
- PSH [C:\Foo]: c:\foo\get-VMMemory.ps1 Foo21
- On Server Foo21 there are 2 VMs as follows:
- Virtual Machine Memory
- SQL-2008-R2-CTP 768
- Server-2008-R2 768
- .EXAMPLE
- PSH [C:\Foo]: "Server2" | c:\foo\get-VMMemory.ps1 Foo21
- On Server Server2 there are 3 VMs as follows:
- Virtual Machine Memory
- Server-2008-R2-1 768
- Server-2008-R2-2 768
- Server-2008-R2-3 768
- #>
- # Parameter is the machine to look at
- param (
- [Parameter(Position=0, Mandatory=$false,ValueFromPipeLine=$true)]
- [string] $Computer = "MyServer"
- )
- ##
- # Start of script
- ##
- # Import the module
- Import-Module HyperV
- # Get all the VMs on the target system
- $Vms = Get-Vm -Server $Computer
- # Now loop through the VMs and display memory allocated
- "On Server {0} there are {1} VMs as follows:" -f $Computer,$Vms.count
- "{0,-30} {1,10}" -f "Virtual Machine", "Memory"
- Foreach ($Vm in $Vms) {
- $Mem = Get-Vmmemory $Vm
- "{0,-30} {1,10}" -f $Vm.Elementname,$Mem.Virtualquantity
- }
- # End of script
Labels:
Codeplex,
Hyper-V,
PowerShell scripts,
PowerShell V2
Subscribe to:
Posts (Atom)