Using DSC v3 to change location of user folders. #1549
Unanswered
ward-horsfall
asked this question in
Q&A
Replies: 2 comments
-
|
Hi you can yous those 2 approche Option 1: $schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
metadata:
Microsoft.DSC:
requiredSecurityContext: current # this is the default and just used as an example indicating this config works for admins and non-admins
resources:
- type: Microsoft.DSC.Transitional/PowerShellScript
name: CreateSelfSignedCertificate
properties:
GetScript: |
@{
Result = (Test-Path 'C:\DestFolder')
}
TestScript: |
if (Test-Path "C:\DestFolder") {
$true
} else {
$false
}
SetScript: |
Copy-Item -Path 'C:\SourceFolder' -Destination 'C:\DestFolder' -Recurse -ForceOption 2: Baseon dscv 2 Configuration CopyFolderExample
{
Import-DscResource -ModuleName PSDesiredStateConfiguration
Node localhost
{
File CopyFolder
{
Ensure = 'Present'
Type = 'Directory'
SourcePath = 'C:\SourceFolder'
DestinationPath = 'D:\TargetFolder'
Recurse = $true
MatchSource = $true
}
}
}
CopyFolderExample
Start-DscConfiguration -Path .\CopyFolderExample -Wait -Verbose -Force
Setup Config $schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: CopyFolder
type: Microsoft.DSC/PowerShell
properties:
resources:
- name: DirectoryCopy
type: PSDesiredStateConfiguration/File
properties:
Ensure: Present
Type: Directory
SourcePath: C:\SourceFolder
DestinationPath: D:\TargetFolder
Recurse: true
MatchSource: true
|
Beta Was this translation helpful? Give feedback.
0 replies
-
|
I'm not aware of an existing DSC resource to do this, but looking at https://support.microsoft.com/en-us/topic/how-to-redirect-user-shell-folders-to-a-specified-path-by-using-profile-maker-ed6289ae-1f9c-b874-4e8c-20d23ea65b2e and finding https://github.com/r3dvorak/userfolder-relocator it wouldn't be difficult to do the same which seems to be changing the registry settings and copying the files to the new location. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi how would I use DSC to move the current user profile folders to a specific path.
Before the folder redirect format a specific disk and create folders
Then:
For example C:\Users\Fred\Documents to F:\Data\Users\Fred\Documents
The same would happen for the other folders like Downloads and so on.
Thanks
Ward
Beta Was this translation helpful? Give feedback.
All reactions