Skip to content

DSC v3 resource for Powershell Profile#26157

Merged
adityapatwardhan merged 20 commits into
PowerShell:masterfrom
adityapatwardhan:DSCResourceProfile
Nov 13, 2025
Merged

DSC v3 resource for Powershell Profile#26157
adityapatwardhan merged 20 commits into
PowerShell:masterfrom
adityapatwardhan:DSCResourceProfile

Conversation

@adityapatwardhan
Copy link
Copy Markdown
Member

@adityapatwardhan adityapatwardhan commented Oct 7, 2025

PR Summary

This pull request introduces a new DSC v3 resource for managing PowerShell profiles across platforms, and integrates it as an experimental feature. The changes include adding resource and script files, updating build configurations to include these files, and modifying workflows to fetch the latest DSC package for CI. The most important changes are grouped below:

PowerShell Profile DSC Resource Implementation:

  • Added new resource manifest (pwsh.profile.dsc.resource.json) and implementation script (pwsh.profile.resource.ps1) to enable management of PowerShell profiles via DSC v3. The resource supports operations to get, set, and export profile content for different profile types. [1] [2]

Experimental Feature Registration:

  • Registered the new resource as an experimental feature PSProfileDSCResource in both configuration files (experimental-feature-linux.json, experimental-feature-windows.json) and in the engine code (ExperimentalFeature.cs). [1] [2] [3]

Build and Packaging Updates:

  • Updated project files for both Unix (powershell-unix.csproj) and Windows (powershell-win-core.csproj) to include the new DSC resource files in the output and publish directories, ensuring they are shipped with builds. [1] [2]

CI Workflow Improvements:

  • Enhanced GitHub Actions workflows for Linux and Windows to dynamically fetch and extract the latest DSC package version, ensuring up-to-date DSC binaries are used during CI runs. [1] [2]

(References: [1] [2] [3] [4] [5] [6] [7] [8] [9]

PR Context

Export all profiles:

 dsc resource export --resource Microsoft.PowerShell/Profile

  PS D:\PSGit\PowerShell> dsc resource export --resource Microsoft.PowerShell/Profile
  $schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
  contentVersion: 1.0.0
  resources:
  - type: Microsoft.PowerShell/Profile
    name: AllUsersCurrentHost
    properties:
      profileType: AllUsersCurrentHost
      content: "Write-Host 'Welcome to your PowerShell profile - AllUsersCurrentHost!'\r\n"
      _exist: true
  - type: Microsoft.PowerShell/Profile
    name: AllUsersAllHosts
    properties:
      profileType: AllUsersAllHosts
      content: "Write-Host 'Welcome to your PowerShell profile - AllUsersAllHosts!'\r\n"
      _exist: true
  - type: Microsoft.PowerShell/Profile
    name: CurrentUserAllHosts
    properties:
      profileType: CurrentUserAllHosts
      content: "# Test profile content currentuser allhosts\r\n"
      _exist: true
  - type: Microsoft.PowerShell/Profile
    name: CurrentUserCurrentHost
    properties:
      profileType: CurrentUserCurrentHost
      content: "Write-Host 'Welcome to your PowerShell profile - CurrentUserCurrentHost!'\r\n"
      _exist: true

Get current user all host

$i = @{ profileType = "CurrentUserAllHosts"} | ConvertTo-Json
dsc resource get --resource Microsoft.PowerShell/Profile -i $i
actualState:
  profileType: CurrentUserAllHosts
  content: '# Test profile content currentuser allhosts'

PR Checklist

@adityapatwardhan adityapatwardhan requested review from a team and jshigetomi as code owners October 7, 2025 19:54
@adityapatwardhan adityapatwardhan changed the title Dsc resource profile DSC v3 resource for Powershell Profile Oct 7, 2025
@adityapatwardhan adityapatwardhan marked this pull request as draft October 7, 2025 19:57
Comment thread .vsts-ci/dsc-resource.yml Outdated
Comment thread dsc/pwsh.profile.dsc.resource.json Outdated
@microsoft-github-policy-service microsoft-github-policy-service Bot added Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept and removed Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept labels Oct 7, 2025
Comment thread dsc/pwsh.profile.dsc.resource.json
Comment thread dsc/pwsh.profile.resource.ps1 Outdated
Comment thread dsc/pwsh.profile.resource.ps1 Outdated
@microsoft-github-policy-service microsoft-github-policy-service Bot added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Oct 11, 2025
@microsoft-github-policy-service microsoft-github-policy-service Bot removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Oct 23, 2025
@microsoft-github-policy-service microsoft-github-policy-service Bot added Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept and removed Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept labels Oct 27, 2025
@microsoft-github-policy-service microsoft-github-policy-service Bot removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Nov 4, 2025
@adityapatwardhan adityapatwardhan force-pushed the DSCResourceProfile branch 2 times, most recently from 2cea1d3 to b962617 Compare November 5, 2025 19:56
@adityapatwardhan adityapatwardhan added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Nov 5, 2025
@adityapatwardhan adityapatwardhan marked this pull request as ready for review November 5, 2025 22:36
adityapatwardhan and others added 4 commits November 5, 2025 14:52
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Comment thread dsc/pwsh.profile.dsc.resource.json
Comment thread dsc/pwsh.profile.dsc.resource.json Outdated
Comment thread dsc/pwsh.profile.dsc.resource.json Outdated
Comment thread dsc/pwsh.profile.dsc.resource.json Outdated
Comment thread dsc/pwsh.profile.dsc.resource.json Outdated
Comment thread dsc/pwsh.profile.resource.ps1 Outdated
@adityapatwardhan adityapatwardhan enabled auto-merge (squash) November 10, 2025 22:38
Comment thread dsc/pwsh.profile.resource.ps1 Outdated
@adityapatwardhan adityapatwardhan merged commit 5715d33 into PowerShell:master Nov 13, 2025
46 of 48 checks passed
@adityapatwardhan adityapatwardhan deleted the DSCResourceProfile branch November 13, 2025 17:56
TravisEz13 pushed a commit to TravisEz13/PowerShell that referenced this pull request Nov 13, 2025
SIRMARGIN pushed a commit to SIRMARGIN/PowerShell that referenced this pull request Dec 12, 2025
kilasuit pushed a commit to kilasuit/PowerShell that referenced this pull request Jan 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backport-7.6.x-Done CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants