maandag 16 juli 2018

How to slipstream a Windows ISO

##--------------------------------------------------------------------------------------------------------------            
## Script for slipstreaming drivers to a windows install iso             
##            
## Prereq.  - Download the Windows ADK for windows 10, install only the Deployment tools and Windows PE !            
##       - Download the latest version of Windows ISO            
##      - Download the drivers to slipstream            
##          - Run this script as administrator!            
##          - Set the variables before running script            
##            
## Copyright Bart Michel            
## Date: 12-07-2018            
##--------------------------------------------------------------------------------------------------------------            
            
## Location of Downloaded files            
$IsoLocation = "C:\Temp\SW_DVD9_Win_Server_STD_CORE_2016_64Bit_English_-4_DC_STD_MLF_X21-70526.ISO"            
$DriverLocation = "C:\Temp\Drivers"            
$Bootorder = "C:\Slipstream\BootOrder.txt"            
            
## Location of directories            
$ExportedISOLocation = "C:\Slipstream\WindowsISO"            
$ExportedDriverLocation = "C:\Slipstream\Drivers"            
$SlipstreamDir = "C:\Slipstream"            
$SourcesDir = "C:\Slipstream\WindowsISO\sources"            
$MountDir = "C:\Slipstream\Mount"            
$oscdimg  = "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\Oscdimg\oscdimg.exe"            
$etfsboot = "C:\Slipstream\WindowsISO\boot\etfsboot.com"            
$efisys   = "C:\Slipstream\WindowsISO\efi\microsoft\boot\efisys.bin"             
$new = "C:\Slipstream\FinishedISO\Windows2016-UCSdrivers.iso"            
$FinishedISOLocation = "C:\Slipstream\FinishedISO\"            
$LogDir = "C:\temp\log.txt"            
            
## Create working dir            
MD C:\Slipstream            
MD C:\Slipstream\Drivers            
MD C:\Slipstream\FinishedISO            
MD C:\Slipstream\Mount            
MD C:\Slipstream\WindowsISO            
            
## Copy Windows ISO to WindowsISO directory            
$mountResult = Mount-DiskImage $IsoLocation -StorageType ISO -PassThru            
$driveLetter = ($mountResult | Get-Volume).DriveLetter            
$driveletter            
$sourceWinISO = $driveletter +":\*"            
Copy-Item -Path $sourceWinISO -Destination $ExportedISOLocation -Recurse -Verbose            
            
## Copy Drivers to slipstream Drivers directory            
Copy-Item -Path $DriverLocation\* -Destination $ExportedDriverLocation -Recurse -Verbose            
            
## Create Bootorder.txt in slipstream directory            
Add-Content $Bootorder "`nboot\bcd`r`nboot\boot.sdi`r`nboot\bootfix.bin`r`nboot\bootsect.exe`r`nboot\etfsboot.com`r`nboot\memtest.exe`r`nboot\en-us\bootsect.exe.mui`r`nboot\fonts\chs_boot.ttf`r`nboot\fonts\cht_boot.ttf`r`nboot\fonts\jpn_boot.ttf`r`nboot\fonts\kor_boot.ttf`r`nboot\fonts\wgl4_boot.ttf`r`nefi\boot\bootx64.efi`r`nefi\microsoft\boot\bcd`r`nefi\microsoft\boot\cdboot.efi`r`nefi\microsoft\boot\cdboot_noprompt.efi`r`nefi\microsoft\boot\efisys.bin`r`nefi\microsoft\boot\efisys_noprompt.bin`r`nefi\microsoft\boot\memtest.efi`r`nefi\microsoft\boot\fonts\chs_boot.ttf`r`nefi\microsoft\boot\fonts\cht_boot.ttf`r`nefi\microsoft\boot\fonts\jpn_boot.ttf`r`nefi\microsoft\boot\fonts\kor_boot.ttf`r`nefi\microsoft\boot\fonts\wgl4_boot.ttf`r`nsources\boot.wim"            
            
## Reomving read-only attribute of Wim files            
Set-ItemProperty $SourcesDir\boot.wim -name IsReadOnly -value $false            
Set-ItemProperty $SourcesDir\install.wim -name IsReadOnly -value $false            
            
## Inject Drivers in Bootwin file            
            
Dism /Mount-Image /ImageFile:$SourcesDir\boot.wim /index:1 /MountDir:$SlipstreamDir\Mount            
Dism /Image:$SlipstreamDir\Mount /Add-Driver /Driver:$SlipstreamDir\Drivers /Recurse             
Dism /Unmount-Wim /Mountdir:$SlipstreamDir\Mount /Commit             
            
Dism /Mount-Image /ImageFile:$SourcesDir\boot.wim /index:2 /MountDir:$SlipstreamDir\Mount             
Dism /Image:$SlipstreamDir\Mount /Add-Driver /Driver:$SlipstreamDir\Drivers /Recurse            
Dism /Unmount-Wim /Mountdir:$SlipstreamDir\Mount /Commit            
            
## Inject Drivers in Install Wil file            
Dism /Mount-Image /ImageFile:$SourcesDir\install.wim /index:1 /MountDir:$SlipstreamDir\Mount            
Dism /Image:$SlipstreamDir\Mount /Add-Driver /Driver:$SlipstreamDir\Drivers /Recurse            
Dism /Unmount-Wim /Mountdir:$SlipstreamDir\Mount /Commit            
            
Dism /Mount-Image /ImageFile:$SourcesDir\install.wim /index:2 /MountDir:$SlipstreamDir\Mount             
Dism /Image:$SlipstreamDir\Mount /Add-Driver /Driver:$SlipstreamDir\Drivers /Recurse             
Dism /Unmount-Wim /Mountdir:$SlipstreamDir\Mount /Commit             
            
Dism /Mount-Image /ImageFile:$SourcesDir\install.wim /index:3 /MountDir:$SlipstreamDir\Mount            
Dism /Image:$SlipstreamDir\Mount /Add-Driver /Driver:$SlipstreamDir\Drivers /Recurse             
Dism /Unmount-Wim /Mountdir:$SlipstreamDir\Mount /Commit             
            
Dism /Mount-Image /ImageFile:$SourcesDir\install.wim /index:4 /MountDir:$SlipstreamDir\Mount            
Dism /Image:$SlipstreamDir\Mount /Add-Driver /Driver:$SlipstreamDir\Drivers /Recurse             
Dism /Unmount-Wim /Mountdir:$SlipstreamDir\Mount /Commit            
            
# Create the updated iso.            
$data = '2#p0,e,b"{0}"#pEF,e,b"{1}"' -f $etfsboot, $efisys            
start-process $oscdimg -args @("-bootdata:$data",'-u2','-m','-o','-udfver102', $ExportedISOLocation, $new) -wait -nonewwindow            
            
## Cleaning up            
Dismount-DiskImage -ImagePath $IsoLocation            
RD $SlipstreamDir\Drivers -Recurse -Force            
RD $SlipstreamDir\WindowsISO -Recurse -Force            
RD $SlipstreamDir\Mount -Recurse -Force            
del $SlipstreamDir\BootOrder.txt            
            
## Open File explorer ISO Location            
ii -Path $FinishedISOLocation            
            
## Console output to log and open            
$psise.CurrentPowerShellTab.ConsolePane.Text | Set-Content -Path $LogDir            
ii -Path $LogDir            
            
Download Script Slipstream.ps1       

dinsdag 21 november 2017

Add Fibre channel Adapter Hyper-v 2016

When you want to add an Virtual Fibre adapter to an VM you will get an error like


When this happens you have to set the VirtualizationBasedSecurityOptOut  to $true:
Set-VMSecurity -vmname "vmname" -VirtualizationBasedSecurityOptOut $true


After changing this you will be able to add an virtual fibre channel adapter







woensdag 1 november 2017

Users in Azure groups

Below command makes connection to you Azure environment and looks which users are in the Azure predefined groups

# Connect to MSOL
$UserCredential = Get-Credential
Connect-MsolService -Credential $UserCredential


# Get all users from azure groups
$roles = Get-MsolRole

foreach ($role in $roles)
{
    write-host $role.Name -ForegroundColor Green
    Get-MsolRoleMember -RoleObjectId $role.ObjectId
}

maandag 15 mei 2017

Failover Cluster Settings 2012r2 VS 2016 (Hyper-V)

Below an overview of all the differences of the available settings of a Windows failover cluster between a 2012r2 cluster and a 2016 cluster.

Hyper-v 2012 R2 Cluster settings
Hyper-V 2016 Cluster settings
Remark
AddEvictDelay                           : 60
AddEvictDelay                           : 60

AdministrativeAccessPoint               : ActiveDirectoryAndDns
AdministrativeAccessPoint               : ActiveDirectoryAndDns

BackupInProgress                        : 0
BackupInProgress                        : 0

BlockCacheSize                          : 0
BlockCacheSize                          : 0

ClusSvcHangTimeout                      : 60
ClusSvcHangTimeout                      : 135
New value
ClusSvcRegroupOpeningTimeout            : 5

Depricated
ClusSvcRegroupPruningTimeout            : 5

Depricated
ClusSvcRegroupStageTimeout              : 10
ClusSvcRegroupStageTimeout              : 10

ClusSvcRegroupTickInMilliseconds        : 300
ClusSvcRegroupTickInMilliseconds        : 300

ClusterEnforcedAntiAffinity             : 0
ClusterEnforcedAntiAffinity             : 0

ClusterGroupWaitDelay                   : 120
ClusterGroupWaitDelay                   : 120

ClusterLogLevel                         : 3
ClusterLogLevel                         : 3

ClusterLogSize                          : 300
ClusterLogSize                          : 300

CrossSubnetDelay                        : 1000
CrossSubnetDelay                        : 1000

CrossSubnetThreshold                    : 20
CrossSubnetThreshold                    : 20

CsvBalancer                             : 1
CsvBalancer                             : 1

DatabaseReadWriteMode                   : 1
DatabaseReadWriteMode                   : 0
New value
DefaultNetworkRole                      : 2
DefaultNetworkRole                      : 3
New value
Description                             :
Description                             :

Domain                                  : Name.local
Domain                                  : Name.LOCAL

DrainOnShutdown                         : 1
DrainOnShutdown                         : 1

DynamicQuorum                           : 1
DynamicQuorum                           : 1

EnableSharedVolumes                     : Enabled
EnableSharedVolumes                     : Enabled

FixQuorum                               : 0
FixQuorum                               : 0

HangRecoveryAction                      : 3
HangRecoveryAction                      : 3

Id                                      :
Id                                      :

IgnorePersistentStateOnStartup          : 0
IgnorePersistentStateOnStartup          : 0

LogResourceControls                     : 0
LogResourceControls                     : 0

LowerQuorumPriorityNodeId               : 0
LowerQuorumPriorityNodeId               : 0

MessageBufferLength                     : 50
MessageBufferLength                     : 50

MinimumNeverPreemptPriority             : 3000
MinimumNeverPreemptPriority             : 3000

MinimumPreemptorPriority                : 1
MinimumPreemptorPriority                : 1

Name                                    : CLU03
Name                                    : CLU03

NetftIPSecEnabled                       : 1
NetftIPSecEnabled                       : 1

PlumbAllCrossSubnetRoutes               : 0
PlumbAllCrossSubnetRoutes               : 0

PreventQuorum                           : 0
PreventQuorum                           : 0

QuorumArbitrationTimeMax                : 90
QuorumArbitrationTimeMax                : 90

RecentEventsResetTime                   : 10-5-2017 09:07:41
RecentEventsResetTime                   : 9-5-2017 07:42:18

RequestReplyTimeout                     : 60
RequestReplyTimeout                     : 60

RootMemoryReserved                      : 512

Depricated
RouteHistoryLength                      : 10
RouteHistoryLength                      : 10

SameSubnetDelay                         : 1000
SameSubnetDelay                         : 1000

SameSubnetThreshold                     : 10
SameSubnetThreshold                     : 10

SecurityLevel                           : 1
SecurityLevel                           : 1

SharedVolumeCompatibleFilters           : {}
SharedVolumeCompatibleFilters           : {}

SharedVolumeIncompatibleFilters         : {}
SharedVolumeIncompatibleFilters         : {}

SharedVolumeSecurityDescriptor          : {1, 0, 4, 128...}
SharedVolumeSecurityDescriptor          : {1, 0, 4, 128...}

SharedVolumesRoot                       : C:\ClusterStorage
SharedVolumesRoot                       : C:\ClusterStorage

SharedVolumeVssWriterOperationTimeout   : 1800
SharedVolumeVssWriterOperationTimeout   : 1800

ShutdownTimeoutInMinutes                : 24
ShutdownTimeoutInMinutes                : 24

UseClientAccessNetworksForSharedVolumes : 0
UseClientAccessNetworksForSharedVolumes : 2
New value
WitnessDatabaseWriteTimeout             : 300
WitnessDatabaseWriteTimeout             : 300

WitnessDynamicWeight                    : 1
WitnessDynamicWeight                    : 1

WitnessRestartInterval                  : 15
WitnessRestartInterval                  : 15


AutoAssignNodeSite                      : 0
New

AutoBalancerLevel                       : 1
New

AutoBalancerMode                        : 2
New

ClusterFunctionalLevel                  : 9
New

ClusterUpgradeVersion                   : 8
New

CrossSiteDelay                          : 1000
New

CrossSiteThreshold                      : 20
New

DumpPolicy                              : 34672921
New

GroupDependencyTimeout                  : 600
New

PlacementOptions                        : 0
New

PreferredSite                           :
New

QuarantineDuration                      : 7200
New

QuarantineThreshold                     : 3
New

ResiliencyDefaultPeriod                 : 240
New

ResiliencyLevel                         : AlwaysIsolate
New

S2DBusTypes                             : 0
New

S2DCacheBehavior                        : Default
New

S2DCacheDesiredState                    : Enabled
New

S2DCacheMetadataReserveBytes            : 34359738368
New

S2DCachePageSizeKBytes                  : 16
New

S2DEnabled                              : 0
New

S2DIOLatencyThreshold                   : 10000
New

S2DOptimizations                        : 0
New