-
Notifications
You must be signed in to change notification settings - Fork 65
VhdFile
dscbot edited this page Jun 12, 2022
·
3 revisions
Parameter | Attribute | DataType | Description | Allowed Values |
---|---|---|---|---|
VhdPath | Key | String | Path to the VHD. | |
FileDirectory | Required | DSC_FileDirectory[] | The FileDirectory objects to copy to the VHD (as used in the File resource). | |
CheckSum | Write | String | Indicates the checksum type to use when determining whether two files are the same. The default value is ModifiedDate . |
ModifiedDate , SHA-1 , SHA-256 , SHA-512
|
Parameter | Attribute | DataType | Description | Allowed Values |
---|---|---|---|---|
DestinationPath | Required | String | Indicates the location where you want to ensure the state for a file or directory. | |
SourcePath | Write | String | Indicates the path from which to copy the file or folder resource. | |
Ensure | Write | String | Indicates if the file or directory exists. Set this property to Absent to ensure that the file or directory does not exist. Set it to Present to ensure that the file or directory does exist. |
Present , Absent
|
Type | Write | String | Indicates if the resource being configured is a directory or a file. Set this property to Directory to indicate that the resource is a directory. Set it to File to indicate that the resource is a file. |
File , Directory
|
Recurse | Write | Boolean | Indicates if subdirectories are included. Set this property to $true to indicate that you want subdirectories to be included. |
|
Force | Write | Boolean | Certain file operations (such as overwriting a file or deleting a directory that is not empty) will result in an error. Using the Force property overrides such errors. | |
Content | Write | String | Specifies the contents of a file, such as a particular string. | |
Attributes | Write | StringArray[] | Specifies the desired state of the attributes for the targeted file or directory. |
ReadOnly , Hidden , System , Archive
|
Manages files or directories in a VHD.
You can use it to copy files/folders to the VHD, remove files/folders from a VHD, and change attributes of a file in a VHD (e.g. change a file attribute to 'ReadOnly' or 'Hidden').
This resource is particularly useful when bootstrapping DSC Configurations into a VM.
- The Hyper-V Role has to be installed on the machine.
- The Hyper-V PowerShell module has to be installed on the machine.
Not yet written.
Configuration Example
{
param
(
[Parameter()]
$vhdPath = 'C:\temp\disk.vhdx',
[Parameter()]
$relativeDestinationPath = 'Temp',
[Parameter()]
[ValidateSet ('Archive', 'Hidden', 'ReadOnly', 'System' )]
$attribute = 'Archive'
)
Import-DscResource -ModuleName 'HyperVDsc'
VhdFile Change-Attribute
{
VhdPath = $vhdPath
FileDirectory = DSC_FileDirectory
{
DestinationPath = $relativeDestinationPath
Attributes = $attribute
}
}
}
Not yet written.
Configuration Example
{
param
(
[Parameter()]
$vhdPath = 'C:\temp\disk.vhdx',
[Parameter()]
$itemToCopy = 'C:\Temp',
[Parameter()]
$relativeDestinationPath = 'Temp'
)
Import-DscResource -ModuleName 'HyperVDsc'
VhdFile FileCopy
{
VhdPath = $vhdPath
FileDirectory = DSC_FileDirectory
{
SourcePath = $itemToCopy
DestinationPath = $relativeDestinationPath
}
}
}
Not yet written.
Configuration Example
{
param
(
[Parameter()]
$vhdPath = 'C:\temp\disk.vhdx',
[Parameter()]
$relativeDestinationPath = 'Temp',
[Parameter()]
$Ensure = 'Absent'
)
Import-DscResource -ModuleName 'HyperVDsc'
VhdFile RemoveFile
{
VhdPath = $vhdPath
FileDirectory = DSC_FileDirectory
{
DestinationPath = $relativeDestinationPath
Ensure = $Ensure
}
}
}