TechShizz | Tech Guides

Data Deduplication

PowerShell Commands for handing Data Deduplication:

# install data deduplication
Install-WindowsFeature -Name FS-Data-Deduplication

# dedup evaluation tool
ddpeval U:
ddpeval I:
ddpeval V:

# enable data deduplication
Enable-DedupVolume -Volume V: -UsageType HyperV

# view and set volume-wide settings
Get-DedupVolume -Volume V: | Format-List *
Set-DedupVolume -Volume V: -MinimumFileAge 0

# manually run optimization job
Start-DedupJob -Type Optimization -Volume V: -Priority High -Memory 100 -Cores 100

# monitor running jobs
Get-DedupJob

# view overall status
Get-DedupStatus | Format-List *

# view and set schedule
Get-DedupSchedule
Set-DedupSchedule -Name ThroughputOptimization -Enabled $false

# disable deduplication
Start-DedupJob -Type Unoptimization -Volume V:

 

Configure a Storage Replica | Server 2016

The below PowerShell commands can be used to configure a Storage Replica.

# install storage replica feature on replication partners
Invoke-Command -ComputerName FS1,FS2 -ScriptBlock { Install-WindowsFeature -Name Storage-Replica,FS-FileServer -IncludeManagementTools -Restart }

# test out a potential partnership
Test-SRTopology -SourceComputerName FS1 -SourceVolumeName R: -SourceLogVolumeName L: `
                -DestinationComputerName FS2 -DestinationVolumeName R: -DestinationLogVolumeName L: `
                -DurationInMinutes 1 -ResultPath c:\logs -IgnorePerfTests

# create a storage replica partnership
New-SRPartnership -SourceComputerName FS1 -SourceRGName FS1RG -SourceVolumeName R: -SourceLogVolumeName L: `
                  -DestinationComputerName FS2 -DestinationRGName FS2RG -DestinationVolumeName R: -DestinationLogVolumeName L:

# view replication status
(Get-SRGroup).Replicas
Get-WinEvent -ProviderName Microsoft-Windows-StorageReplica

# add some files to the source volume
"Hello!" > r:\file.txt
"Was it me," > r:\file2.txt
"you were looking for?" > r:\file3.txt
fsutil file createnew r:\file4.dat 1000000000

# reverse replication
Set-SRPartnership -NewSourceComputerName FS2 -SourceRGName FS2RG -DestinationComputerName FS1 -DestinationRGName FS1RG

# remove replication and clean up
Get-SRPartnership | Remove-SRPartnership

Invoke-Command -ComputerName FS1,FS2 -ScriptBlock {
    Get-SRGroup | Remove-SRGroup
}



Create Storage Pools, Virtual Disks and Volumes with Server Manager in Server 2012 / 2016

Here are the PowerShell Commands to complete:

# create a new storage pool
New-StoragePool -FriendlyName AllTheDisks -StorageSubSystemUniqueId (Get-StorageSubSystem).UniqueId -PhysicalDisks (Get-PhysicalDisk -CanPool $true)

# create virtual disk
New-VirtualDisk -FriendlyName CompanyData -StoragePoolFriendlyName AllTheDisks -Size 2TB -ProvisioningType Thin -ResiliencySettingName Mirror

# initialize underlying physical disks
Initialize-Disk -VirtualDisk (Get-VirtualDisk -FriendlyName CompanyData)

# partition and format volumes from virtual disk
$vd = Get-VirtualDisk -FriendlyName CompanyData | Get-Disk

$vd | 
    New-Partition -Size 100GB -Driveletter U |
            Format-Volume -FileSystem NTFS -AllocationUnitSize 4096 -NewFileSystemLabel "User Data"

$vd |     
    New-Partition -Size 500GB -Driveletter I |
        Format-Volume -FileSystem ReFS -AllocationUnitSize 4096 -NewFileSystemLabel "IT Data"

$vd | 
    New-Partition -Size 1TB -Driveletter V |
        Format-Volume -FileSystem ReFS -AllocationUnitSize 65536 -NewFileSystemLabel "VM Data"

 

Using DISM to Add Drivers / Packages / Install Roles and Features in a .wim file

The following reference folders that contain the relevent drivers/packages. Ensure you have the driver/package in the right location e.g. .\drivers

### DISM - Deployment Image Servicing and Management Command-line Utility ###

## Desktop Experience & Server Core ##

# display help
dism /?

# view images within a .wim
dism /get-imageinfo /imagefile:.\images\install.wim

# mount server core datacenter image
dism /mount-image /imagefile:.\images\install.wim /index:3 /mountdir:.\mount

# add drivers (.inf)
dism /image:.\mount /get-drivers
dism /image:.\mount /add-driver /driver:.\drivers
dism /image:.\mount /remove-driver /driver:.\drivers\iaStorAC.inf

# add patches, hotfixes, and updates (.msu or .cab)
dism /image:.\mount /get-packages
dism /image:.\mount /add-package /packagepath:.\updates
dism /image:.\mount /remove-package /packagepath:.\updates\windows10.0-kb3150513.msu

# install roles and features
dism /image:.\mount /get-features
dism /image:.\mount /get-featureinfo /featurename:web-server
dism /image:.\mount /enable-feature /featurename:web-server /all
dism /image:.\mount /disable-feature /featurename:web-server

# dismount and commit all changes
dism /unmount-image /mountdir:.\mount /commit


## Nano Server ##

# view nano server images
dism /get-imageinfo /imagefile:.\images\nanoserver.wim

# mount nano server datacenter image
dism /mount-image /imagefile:.\images\nanoserver.wim /index:2 /mountdir:.\mount

# add nano server package
dism /image:.\mount /add-package /package:d:\nanoserver\packages\microsoft-nanoserver-containers-package.cab

# dismount and commit all changes
dism /unmount-image /mountdir:.\mount /discard

 

Using PowerShell to Add Drivers / Packages / Install Roles and Features in a .wim file

The following reference folders that contain the relevent drivers/packages. Ensure you have the driver/package in the right location e.g. .\drivers

### DISM - Deployment Image Servicing and Management PowerShell Cmdlets ###

## .wim ##

# view cmdlets in DISM module
Get-Command -Module DISM

# view images within a .wim
Get-WindowsImage -ImagePath .\images\install.wim
Get-WindowsImage -ImagePath .\images\nanoserver.wim

# mount server core datacenter image
Mount-WindowsImage -ImagePath .\images\install.wim -Path .\mount -Index 3

# add drivers (.inf)
Get-WindowsDriver -Path .\mount
Add-WindowsDriver -Path .\mount -Driver .\drivers\iaStorAC.inf

# add packages (.msu or .cab)
Get-WindowsPackage -Path .\mount
Add-WindowsPackage -Path .\mount -PackagePath .\updates\windows10.0-kb3150513.msu

# install roles and features
Get-WindowsOptionalFeature -Path .\mount -FeatureName dhcpserver
Enable-WindowsOptionalFeature -Path .\mount -FeatureName dhcpserver
Disable-WindowsOptionalFeature -Path .\mount -FeatureName dhcpserver

# dismount and commit changes
Dismount-WindowsImage -Path .\mount -Save


## .vhd/vhdx ##

# mount nano server datacenter vhd
Mount-WindowsImage -ImagePath .\image\nanoserver.wim -Path .\mount -Index 2

# add iis package
Add-WindowsPackage -Path .\mount -PackagePath d:\nanoserver\packages\microsoft-nanoserver-iis-package.cab

# dismount and commit changes
Dismount-WindowsImage -Path .\mount -Save