Skip to content

Commit

Permalink
Sample added
Browse files Browse the repository at this point in the history
  • Loading branch information
nyanhp committed Jan 18, 2023
1 parent e2f6a4f commit 9c0ea13
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
9 changes: 9 additions & 0 deletions source/Classes/002.FileSystemObject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,15 @@ class FileSystemObject
Reasons = @()
}

if ($this.Type -eq [objectType]::directory -and -not [string]::IsNullOrWhiteSpace($this.Contents))
{
Write-Verbose -Message "Type is directory, yet parameter Contents was used."
$returnable.Reasons += @{
Code = "File:File:ParameterMismatch"
Phrase = "Type is directory, yet parameter Contents was used."
}
}

$object = Get-Item -ErrorAction SilentlyContinue -Path $this.DestinationPath -Force
if ($null -eq $object -and $this.Ensure -eq [ensure]::present)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<#PSScriptInfo
.VERSION 1.0.0
.GUID e479ea7f-0427-40a5-96ab-17215511b05f
.AUTHOR DSC Community
.COMPANYNAME DSC Community
.COPYRIGHT DSC Community contributors. All rights reserved.
.TAGS DSCConfiguration
.LICENSEURI https://github.com/dsccommunity/FileSystemDsc/blob/main/LICENSE
.PROJECTURI https://github.com/dsccommunity/FileSystemDsc
.ICONURI https://dsccommunity.org/images/DSC_Logo_300p.png
.RELEASENOTES
First release.
#>

#Requires -Module FileSystemDsc

Configuration FileSystemObject_CreateFileWithContent_Config
{
Import-DscResource -ModuleName FileSystemDsc

node localhost
{
FileSystemObject MyFile
{
DestinationPath = 'C:\inetpub\wwwroot\index.html'
Contents = '<html><head><title>My Page</title></head><body>DSC is the best</body></html>'
Type = 'file'
Ensure = 'present'
}
}
}

0 comments on commit 9c0ea13

Please sign in to comment.