Files
PowerShell_Adv_Automation/Exercise Files/01_04/01_04.ps1
Iwan Clement 1808f43f53 first commit
2020-11-03 18:55:20 +01:00

55 lines
1.4 KiB
PowerShell
Executable File

Install-Module xSmbShare
Install-Module cNtfsAccessControl
Configuration SMBPull
{
Import-DscResource -ModuleName PSDesiredStateConfiguration
Import-DscResource -ModuleName xSmbShare
Import-DscResource -ModuleName cNtfsAccessControl
Node localhost
{
File CreateFolder
{
DestinationPath = 'C:\DSCSMB'
Type = 'Directory'
Ensure = 'Present'
}
xSMBShare CreateShare
{
Name = 'DscSmbPull'
Path = 'C:\DSCSMB'
FullAccess = 'landonhotel\administrator'
ReadAccess = 'landonhotel\srv02$'
FolderEnumerationMode = 'AccessBased'
Ensure = 'Present'
DependsOn = '[File]CreateFolder'
}
cNtfsPermissionEntry PermissionSet1
{
Ensure = 'Present'
Path = 'C:\DSCSMB'
Principal = 'landonhotel\srv02$'
AccessControlInformation = @(
cNtfsAccessControlInformation
{
AccessControlType = 'Allow'
FileSystemRights = 'ReadAndExecute'
Inheritance = 'ThisFolderSubfoldersAndFiles'
NoPropagateInherit = $false
}
)
DependsOn = '[File]CreateFolder'
}
}
}
SmbPull
Start-DscConfiguration -Path SmbPull -Wait -Verbose