microsoft / microsoft/sql-server-samples
Get-ChildItem vs Microsoft.SqlServer.Management.DMF.PolicyStore
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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