Skip to content

Commit fd32f07

Browse files
committed
Corrections as per PR comments
1 parent f7688b5 commit fd32f07

3 files changed

Lines changed: 99 additions & 189 deletions

File tree

DSCResources/MSFT_xVirtualMemory/MSFT_xVirtualMemory.psm1

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function Get-TargetResource
4242
MaximumSize = 0
4343
}
4444

45-
[bool] $isSystemManaged = (Get-CimInstance -ClassName 'Win32_ComputerSystem').AutomaticManagedPagefile
45+
[System.Boolean] $isSystemManaged = (Get-CimInstance -ClassName 'Win32_ComputerSystem').AutomaticManagedPagefile
4646

4747
if ($isSystemManaged)
4848
{
@@ -58,21 +58,22 @@ function Get-TargetResource
5858
if (-not $existingPageFileSetting)
5959
{
6060
$returnValue.Type = 'NoPagingFile'
61-
return $returnValue
62-
}
63-
64-
if ($existingPageFileSetting.InitialSize -eq 0 -and $existingPageFileSetting.MaximumSize -eq 0)
65-
{
66-
$returnValue.Type = 'SystemManagedSize'
6761
}
6862
else
6963
{
70-
$returnValue.Type = 'CustomSize'
71-
}
64+
if ($existingPageFileSetting.InitialSize -eq 0 -and $existingPageFileSetting.MaximumSize -eq 0)
65+
{
66+
$returnValue.Type = 'SystemManagedSize'
67+
}
68+
else
69+
{
70+
$returnValue.Type = 'CustomSize'
71+
}
7272

73-
$returnValue.Drive = $existingPageFileSetting.Name.Substring(0, 3)
74-
$returnValue.InitialSize = $existingPageFileSetting.InitialSize
75-
$returnValue.MaximumSize = $existingPageFileSetting.MaximumSize
73+
$returnValue.Drive = $existingPageFileSetting.Name.Substring(0, 3)
74+
$returnValue.InitialSize = $existingPageFileSetting.InitialSize
75+
$returnValue.MaximumSize = $existingPageFileSetting.MaximumSize
76+
}
7677

7778
return $returnValue
7879
}
@@ -382,6 +383,20 @@ function Get-PageFileSetting
382383
-Filter "SettingID='pagefile.sys @ $Drive'"
383384
}
384385

386+
<#
387+
.SYNOPSIS
388+
Sets a new page file name.
389+
390+
.PARAMETER Drive
391+
The letter of the drive containing the page file
392+
to change the settings of.
393+
394+
.PARAMETER InitialSize
395+
The initial size to set the page file to.
396+
397+
.PARAMETER MaximumSize
398+
The maximum size to set the page file to.
399+
#>
385400
function Set-PageFileSetting
386401
{
387402
[CmdletBinding()]

DSCResources/MSFT_xVirtualMemory/en-US/MSFT_xVirtualMemory.strings.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ConvertFrom-StringData @'
44
SetAutoManagePagingMessage = {0} automatically managed page file.
55
GettingPageFileSettingsMessage = Getting page file settings for drive {0}.
66
SettingPageFileSettingsMessage = Setting page file settings for drive {0} with initial size of {1}MB and maximum size {2}MB.
7-
NewPageFileMessage = Specifting new page file '{0}'.
7+
NewPageFileMessage = Creating new page file '{0}'.
88
RemovePageFileMessage = Removing existing page file '{0}'.
99
DisabledPageFileMessage = Disabled page file for drive {0}.
1010
EnabledSystemManagedSizeMessage = Enabled system managed page file for drive {0}.

0 commit comments

Comments
 (0)