Create an OS Image in Windows Deployment Services (Capture Image)

Here I will show you how you can simple create a new Image in WDS (Windows Deployment Services). You can use this to create own Images for your Servers or PCs or update existing Images.

  1. Add Capture Images to your WDS
    Windows Deployment Services
  2. Update your Computer or VM with the latest Software.
    Windows Deployment Services
  3. Use Sysprep to generalize the Machine. You can find sysprep.exe in C:\Windows\System32\sysprep
    Sysprep
  4. After the Reboot boot into PXE and boot the Windows Capture Image
    Capture Image
  5. Now you can use the Image Capture Wizard
    Capture Image Wizard
  6. Choose which volume you want to capture if you have just one partion in your installed Image the Volume would be D:\ (C: is the booted Windows PE from the Windows Deployment Service)
    Capture Volume
  7. Now you have to choose the name of the WIM file and the location, before you can upload it to the WDS Server you have to save it on a local partion. After that you can choose your WDS Server and the Image Group you want to upload the image after the Volume is captured.
    Image
  8. Now the capturing process will start
  9. After the capturing process is finished and the image is uploaded you can find the Image in the Image group on your WDS Server
    Capture ImageWDS
  10. Now you can Rollout this new Image

Powershell for System Center Virtual Machine Manager and Hyper-V

Microsoft System Center Virtual Machine Manager 2008 R2

This little HowTo shows you how can you get tasks on System Center Virtual Machine Manager done, by using Windows Powershell.

Load Powershell Snapin for Virtual Machine Manager:

Add-PSSnapin Microsoft.SystemCenter.VirtualMachineManager

Create Virtual Machine:

# Config
# ------------------------------------
# Job Config
$JobGroup = "0000001" # This is used to group command by a job
$SCMVVMServer = "SCVVMServer01" # Name of the SCVMM Server (could also be localhost)

# Network Config
$VirtualNetwork = "External" # Name of the Network you want the VM to connect
$VLanEnable = $true # eable VLANs
$VLANID = "1023" # VLAN ID

# VMM Config
$Domain = "Contoso"
$Owner = "Ownerusername" # Owner User
$Description = "This is a Server" # Choose a Description
$VMName = "server05" # Name of the VM
$VMHost = "hyperv02" # Name of the existing VM Host
$VMPath = "C:\ProgramData\Microsoft\Windows\Hyper-V"

# Virtual Machine Config
$VMOperatingSystem = "64-bit edition of Windows Server 2008 R2 Standard"
$CPU = "1.20 GHz Athlon MP" # CPU
$VMDiskSize = "40960" # Disk Size in MB
$CPUCount = "1"
$MemoryMB = "1024" # Memory Size in MB
$ExpectedCPUUtilization = "20"
$DiskIO = "0"
$CPUMax = "100"
$CPUReserve = "0"
$NetworkUtilization = "0"
$RelativeWeight = "100"
$HighlyAvailable = $false
$NumLock = $false
$BootOrder = "CD", "IdeHardDrive", "PxeBoot", "Floppy"
$LimitCPUFunctionality = $false
$LimitCPUForMigration = $false

# Setup Process
# ------------------------------------
Set-VirtualFloppyDrive -RunAsynchronously -VMMServer $SCVMMServer -NoMedia -JobGroup $JobGroup
Set-VirtualCOMPort -NoAttach -VMMServer $SCVMMServer -GuestPort 1 -JobGroup $JobGroup
Set-VirtualCOMPort -NoAttach -VMMServer $SCVMMServer -GuestPort 2 -JobGroup $JobGroup
New-VirtualNetworkAdapter -VMMServer $SCVMMServer -JobGroup $JobGroup -PhysicalAddressType Dynamic -VirtualNetwork $VirtualNetwork -VLanEnabled $VLanEnable -VLANID $VLANID -MACAddressesSpoofingEnabled $false
$CPUType = Get-CPUType -VMMServer $SCVMMServer | where {$_.Name -eq $CPU}
New-HardwareProfile -VMMServer $SCVMMServer -Owner ($Domain + "\" + $Owner) -CPUType $CPUType -Name ("Profile" + $JobGroup) -CPUCount $CPUCount -MemoryMB $MemoryMB -ExpectedCPUUtilization $ExpectedCPUUtilization -DiskIO $DiskIO -CPUMax $CPUMax -CPUReserve $CPUReserve -NetworkUtilization $NetworkUtilization -RelativeWeight $RelativeWeight -HighlyAvailable $HighlyAvailable -NumLock $XMLTask.Feature.NumLock -BootOrder $BootOrder -LimitCPUFunctionality $LimitCPUFunctionality -LimitCPUForMigration $LimitCPUForMigration -JobGroup $JobGroup
New-VirtualDiskDrive -VMMServer $SCVMMServer -IDE -Bus 0 -LUN 0 -JobGroup $JobGroup -Size $VMDiskSize -Dynamic -Filename ($VMName + "_disk_1")
$VMHost = Get-VMHost -VMMServer $SCVMMServer | where {$_.Name -eq $VMHost}
$HardwareProfile = Get-HardwareProfile -VMMServer $SCVMMServer | where {$_.Name -eq ("Profile" + $JobGroup)}
$OperatingSystem = Get-OperatingSystem -VMMServer $SCVMMServer | where {$_.Name -eq $VMOperatingSystem}

# Create VM
# ------------------------------------
New-VM -VMMServer $SCVMMServer -Name $VMName -Description $Description -Owner ($Domain + "\" + $Owner) -VMHost $VMHost -Path $VMPath -HardwareProfile $HardwareProfile -JobGroup $JobGroup -RunAsynchronously -OperatingSystem $OperatingSystem -RunAsSystem -StartAction NeverAutoTurnOnVM -StopAction SaveVM

Delete (Remove) Virtual Machine:

# Config
# ------------------------------------
$VMName = "server05" # Name of the VM

# Setup Process
# ------------------------------------
$SelectedVM = Get-VM -Name $VMName

# Remove/Delete VM
# ------------------------------------
Remove-VM -VM $SelectedVM

Suspend Virtual Machine:

# Config
# ------------------------------------
$VMName = "server05" # Name of the VM

# Setup Process
# ------------------------------------
$SelectedVM = Get-VM -Name $VMName

# Suspend VM
# ------------------------------------
Suspend-VM -VM $SelectedVM

Resume Virtual Machine:

# Config
# ------------------------------------
$VMName = "server05" # Name of the VM

# Setup Process
# ------------------------------------
$SelectedVM = Get-VM -Name $VMName

# Resume VM
# ------------------------------------
Resume-VM -VM $SelectedVM

Stop Virtual Machine / Turn off Virtual Machine:

# Config
# ------------------------------------
$VMName = "server05" # Name of the VM

# Setup Process
# ------------------------------------
$SelectedVM = Get-VM -Name $VMName

# Stop / Turn off VM
# ------------------------------------
Stop-VM -VM $SelectedVM

Start Virtual Machine:

# Config
# ------------------------------------
$VMName = "server05" # Name of the VM

# Setup Process
# ------------------------------------
$SelectedVM = Get-VM -Name $VMName

# Start VM
# ------------------------------------
Start-VM -VM $SelectedVM

This is a reference how you can do some thing with Powershell in the Virtual Machine Manager. You can do a lot more, like error handling, creating virtual machines from a xml config file etc…

How to Backup a Sharepoint 2010 Site Collection with Powershell

Powershell HeaderOkay for a real backup solution you should use a backup software like Microsoft System Center Data Protection Manager or Symantec Backup Exec. But maybe you have customer which needs a backup of his Sharepoint Site Collection. You also could use the Backup Tool in the Sharepoint Central Administration, but if you need to automate that, you will need Powershell.

Backup a Site Collection:

Backup-SPSite -Identity "http://sharepoint.company.com" -Path "C:\Temp\backup1.bak" -Force

Restore a Site Collection:

Restore-SPSite "http://sharepoint.company.com" -Path C:\backup1.bak -HostHeaderWebApplication "http://WebAppname" -Force -Confirm:$False

How to redirect sites to HTTPS in IIS 7.5

This little guide shows you how you can redirect http request to the https website using IIS Settings. You can do the same on other versions of IIS slightly different.

  1. First set “require SSL” under the SSL Settings from the Website
    SSL Settings
  2. Under the Error Page Settings edit the 403 Error Page
    Error Page Settings
  3. mark the Setting “Respond with a 302 redirect” and add the https URL
    Respond with a 302 redirect

How to add a Windows Server 2008 R2 Core as Secondary DNS Server

This shows you how you can add a secondary DNS Server to your Network on a Windows Server 2008 R2 Core.

  1. As usual you configure the Windows Server 2008 R2 Core with Sconfig
  2. Now install the DNS Server role on the Windows Server 2008 R2 Core
    Windows Server 2008 R2 Core DNS Serverstart /w ocsetup DNS-Server-Core-Role
  3. On the primary DNS Server open the DNS Server MMC
  4. Right click properties on the DNS zones you wanna transfer to the new core server
  5. Add the new DNS Server in the Name Server Tab. In this case this is server04.corp.pepsi.local
    Windows Server 2008 R2 DNS Server
  6. Allow Zone Transfers to this Server or Server in the Name Servers Tab
    Windows Server 2008 R2 DNS Server

How to add a Windows Server 2008 R2 Core as Secondary Domain Controller (replica)

This is a small How to which shows you how you can add a Windows Server 2008 R2 Core as a Secondary Domain Controller or Replica.

  1. sconfig Windows Server 2008 R2First configure the Core Server, Name, Domain, IP Adresse and more. You can use the command sconfig to run the Server Configuration Utility.
  2. Now you can go back to the Command Promt.
  3. Now you have to possibilities to install a Domain Controller. First you run dcpromo with a unattend file you have created and copied on the server, or you run dcpromo with some parameters. I decided to run dcpromo with the necessary parameters because I just need a simple replica.
  4. Now you can run the command on the Command Promt
    Dcpromo Windows Server 2008 R2 Core Dcpromo /unattend /replicaOrnewDomain:replica /replicaDomainDNSName:corp.pepsi.local /ConfirmGC:yes /username:corp’administrator /Password:* /safeModeAdminPassword:PepsiPassword
  5. After that the Server will run the installer and reboot.
    Windows Server 2008 R2 Core DCPROMO
  6. A replication connection was created
    Windows Server 2008 R2 AD Replication

If you need more Information about Active Directory Creation on a Windows Server 2008 Core Server you can checkout the Microsoft KB947034.