On the web I can't find much about invoking policy evaluation via the PowerShell Cmdlet Invoke-PolicyEvaluation with SQL Server authentication.
Something like this worked in the past, but after upgrading to SQL Server 2016 it won't work. It works with Windows authentication.
$conn = New-Object Microsoft.SqlServer.Management.Sdk.Sfc.SqlStoreConnection("Server=$ServerName;Integrated Security=False;User=PolicyEvaluation;Password=...")
Get-ChildItem | Where-Object {$_.Name -eq $Policy.Name} | Invoke-PolicyEvaluation -TargetServerName $conn -AdHocPolicyEvaluationMode $EvalMode -OutputXML > $OutputFile
I get this error:
Get-ChildItem : SQL Server PowerShell provider error: Failed to read child items. [The pipeline has been stopped.]At D:\EnterprisePolicyManagement\PowerShell\EPM_EnterpriseEvaluation_412.ps1:278 char:6
+ Get-ChildItem | Where-Object {$_.Name -eq $Policy.Name} | Invoke-PolicyEval ...
+ ~~~~~~~~~~~~~
+ CategoryInfo : ReadError: (SQLSERVER:\SQLP...EFAULT\Policies:SqlPath) [Get-ChildItem], GenericProviderException
+ FullyQualifiedErrorId : CannotReadChildItems,Microsoft.PowerShell.Commands.GetChildItemCommand