Commit e6870975 authored by O'Reilly Media, Inc.'s avatar O'Reilly Media, Inc.
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading
+15 −0
Changes for Advanced Windows PowerShell Scripting - Working Files/Chapter 1/0102 - Class notes.txt: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
Download Windows Server 2012 R2 Evaluation
http://www.microsoft.com/en-us/evalcenter/evaluate-windows-server-2012-r2


Hyper-V Installation Prerequisites
https://technet.microsoft.com/en-us/library/Cc731898.aspx

The Microsoft Hardware-Assisted Virtualization Detection Tool

http://social.technet.microsoft.com/wiki/contents/articles/585.the-microsoft-hardware-assisted-virtualization-detection-tool.aspx


PowerShell Code for DEP

Get-CIMInstance -ClassName Win32_OperatingSystem | Select *
 No newline at end of file
+30 −0
Changes for Advanced Windows PowerShell Scripting - Working Files/Chapter 1/CreateDomain.ps1: 30 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Install Active Directory Domain Services
$Hash = @{
    Name = "AD-Domain-Services"
    IncludeManagementTools = $True
    Restart = $True
    Verbose = $True
}
    
Install-WindowsFeature @Hash


# Create the first Domain Controller in our new domain.

Import-Module ADDSDeployment

$ADHash = @{
    CreateDnsDelegation = $false
    DatabasePath = "C:\Windows\NTDS" 
    DomainMode = "Win2012R2" 
    DomainName = "PowerIT.com" 
    DomainNetbiosName = "POWERIT" 
    ForestMode = "Win2012R2" 
    InstallDns = $true 
    LogPath = "C:\Windows\NTDS" 
    NoRebootOnCompletion = $false 
    SysvolPath = "C:\Windows\SYSVOL" 
    Force = $true
    }

Install-ADDSForest @ADHash
+17 −0
Changes for Advanced Windows PowerShell Scripting - Working Files/Chapter 1/Install Hyper-V.ps1: 17 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Verify that Hyper-V is not installed.
Get-WindowsFeature -Name Hyper-V | 
    Select-Object -Property Name, Installed

# Install Hyper -V
Add-WindowsFeature -Name Hyper-V -IncludeAllSubFeature -IncludeManagementTools -Restart

# Install Hyper-V using Splating.

$Splat = @{
    Name = "Hyper-V"
    IncludeAllSubFeature = $True
    IncludeManagementTools = $True
    Restart = $True
}

Add-WindowsFeature @Splat
 No newline at end of file
+65 −0
Changes for Advanced Windows PowerShell Scripting - Working Files/Chapter 1/Setup Hyper-V.ps1: 65 added lines, 0 removed lines.
Original line number Diff line number Diff line
#region Setup Virtual Switches
New-VMSwitch -Name PSTest -SwitchType Private -Notes "Switch for the Sandbox"

# Get a list of all NICs that have a Gateway address.
Get-WmiObject win32_networkAdapterConfiguration |
    Where defaultipgateway -ne $null |
    Select-Object -Property Description |
    Out-GridView -PassThru |
    ForEach-Object -Process {
        $Splat = @{
            NetAdapterInterfaceDescription = $_.Description
            Name = "PSExternal"
            AllowManagementOS = $True
            Notes = "External Switch for the Sandbox"
            Verbose = $True
        }
        New-VMSwitch @Splat  
}

#endregion

#region Create Virtual Machines

# Get the path to the Windows Server 2012 R2 ISO file.
$ISOPath = "e:\Media\9600.16384.WINBLUE_RTM.130821-1623_X64FRE_SERVER_EVAL_EN-US-IRM_SSS_X64FREE_EN-US_DV5.iso"
$VHDPath = "D:\VM"

 # Create the VM.
 $Names = "DC", "SVR1"
 ForEach ($Name in $Names)
 {
   $VMHash = @{BootDevice = "CD"
               MemoryStartupBytes = 512MB
               Name = $Name
               SwitchName = "PSTest"
               NewVHDPath = "$($VHDPath)\$($Name).vhdx";
               NewVHDSizeBytes = 10GB
               Verbose = $True
               }

   New-VM @VMHash 


}

# Configure the DVD drive to point to the ISO file.
 Set-VMDvdDrive -VMName DC -Path $ISOPath -Verbose
  Set-VMDvdDrive -VMName SVR1 -Path $ISOPath -Verbose

# You can adjust the MaximumBytes and MinimumBytes
# to better fit your available RAM.  The settings below
# are for a system with 4 GB of RAM.
$VMMemoryHash = @{
    DynamicMemoryEnabled = $True
    MaximumBytes = 1024MB
    MinimumBytes = 512MB
}
Get-VM -Name DC, SVR1 |
    Set-VMMemory @VMMemoryHash

# If the external NIC was created, run this code.
Get-VM DC, SVR1 | Add-VMNetworkAdapter –Name PSExternal -Verbose
Get-VMSwitch -Name PSExternal |
Connect-VMNetworkAdapter -VMName DC, SVR1 -Name PSExternal -Verbose
#endregion
 No newline at end of file
+19 −0
Changes for Advanced Windows PowerShell Scripting - Working Files/Chapter 1/StartVMs.ps1: 19 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Get the VM objects.
$VMs = Get-VM -VMName DC, SVR1

# Get the name of the local host.
$Hostname = Hostname

# Make sure each VM is started and connect to it.
ForEach ($VM in $VMs)
{
    If ($VM.State -ne "Running")
    {
        Start-VM -VMName $VM.Name
        Invoke-Expression -Command "VMConnect $($HostName) $($VM.Name)"
    }
    Else
    {
        Invoke-Expression -Command "VMConnect $($HostName) $($VM.Name)"
    }
}
 No newline at end of file
Loading