Desired State Configuration (DSC) – Configuration snippet – Custom Resource – Shrink Volume

Shrinks C: to 100GB

Script ShrinkC 

        {
            GetScript = {
                @{
                GetScript = $GetScript
                SetScript = $SetScript
                TestScript = $TestScript
                Result = -not((Get-Partition -DiskNumber 0 | where {$_.DriveLetter -eq "C"} | select -expandProperty Size) -gt 100GB)
                }
            }

            SetScript = {
                Get-Partition -DiskNumber 0 | where {$_.DriveLetter -eq "C"} | Resize-Partition -Size (100GB)
            }

            TestScript = {
                $Status = -not((Get-Partition -DiskNumber 0 | where {$_.DriveLetter -eq "C"} | select -expandProperty Size) -gt 100GB)
                $Status -eq $True
            }
        }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s