microsoft / microsoft/sql-server-samples

Get-ChildItem vs Microsoft.SqlServer.Management.DMF.PolicyStore

Open
#420 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PowerShell
Stars
11.2k
Forks
9.1k
Avg merge
2d 7h
Merged PRs (30d)
14

Description

When I run
Invoke-PolicyEvaluation -Policy $Policy -TargetServerName $ServerName -AdHocPolicyEvaluationMode $EvalMode -OutputXML >> $OutputFile;

The result depends on how I made variable $Policy. If I used default code with $PolicyStore.Policies then it does not work and return exception: ```
Message : Value cannot be null.
Parameter name: policy
ParamName : policy

If I do  
` sl "SQLSERVER:\sqlpolicy\sa\beta\policies"` and `gci | Where-Object { $_.PolicyCategory -eq "Microsoft Best Practices: Maintenance" ...` It works. 
SQL Server 2016 with SSMS 2017. 
Thank you in advance for your help!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Invoke-PolicyEvaluation command with $PolicyStore.Policies, then compare that value with the policy returned by Get-ChildItem from SQLSERVER:\sqlpolicy\sa\beta\policies. Done means the default $PolicyStore.Policies path supplies a valid policy and no longer produces the null-policy exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.