Service stopped? Restart it with PowerShell

In a previous article, I discussed changing a Windows Service Log On Account information using the Set-Service PowerShell cmdlet. Just as the Set-Service cmdlet modifies the properties of a Windows Service, the Get-Service cmdlet gets a Windows Service properties.

 

Running the Get-Service cmdlet without any parameters will list the Status,  Name, and DisplayName of each service on a system. Using the Get-Service cmdlet with a combination of parameters lists the services that match the criteria.
 
Return a list of Services that start with the Name Microsoft:
Get-Service -Name "Microsoft*"
Return a list of Services that begin with Microsoft and do not contain WS:
Get-Service -Name "Microsoft*" -Exclude "*WS*" | Format-Table -Property Name, Status, StartType, DisplayName
Note: You can use the PowerShell Format Commands to change the output view.
Return a list of Services with a Name that begins with Microsoft and a Status of Stopped:
Get-Service -Name "Microsoft*" | Where-Object {$_.Status -eq "Stopped"} | Format-Table -Property Name, Status, StartType, DisplayName
The Set-Service cmdlet modifies service properties, and the Status is one of those properties.
Start the Service with a Name MicrosoftDynamicsNavWS:
Set-Service -Name MicrosoftDynamicsNavWS -Status Running 
 
The service list returned from the Get-Service cmdlet may be piped to the Set-Service cmdlet to restart a stopped service. In this example, services that begin with MicrosoftDynamicsNAV and have a Stopped status pass to the Set-Service cmdlet to start:
Get-Service -Name "MicrosoftDynamicsNav*" | Where-Object {$_.Status -eq "Stopped"} | Set-Service -Status Running

The stopped services with a name beginning with MicrosoftDynamicsNav start on the machine, unless there is something preventing the service from starting.

Note: The code and information discussed in this article is for informational and demonstration purposes only. 

It’s Friday – August 26

Dynamics 365 Business Central: Using Security Filters to Limit Data

Within Microsoft Dynamics 365 Business Central, user access is controlled by assigning User Groups and/or Permission Sets to a user on the User Card. A Permission Set is a group of permissions that control access within Business Central. A User Group is a set of Permission Sets, which simplify the assignment of Permission Sets based on user functions or roles.


Security Filters manage Record Level Security in Dynamics 365 Business Central. Security Filters are applied to TableData Objects in a Permission Set to limit the data for a Permission Set Object. For example, a Security Filter is applied to the Customer TableData object if the need is to restrict the customers available to a permission set.

To Limit Data with a Security Filter:

  1. Search for “Permission Sets” using the “Tell Me” action in the App Bar and click the “Permission Sets” list link
  2. Select the Permission Set that will have the Record Level restriction and click “Permissions” in the action bar
  3. Go to the row for Table Data you would like to filter and click on the ellipsis button in the Security Filter Column.
  4. Enter the Field Number (or select from the list by clicking the ellipsis button in the Field Number Column. The Field Caption will display on the row.
  5. Enter the Field Filter to apply to the selected field Note: Security filters do not support wildcard characters (* or ?)
  6. Repeat Steps 4 and 5 for each field that should have a filter applied
  7. Click Close on the Table Filter Page
  8. Repeat steps 2 through 7 for each TableData Permission that requires a Security Filter

Users with the Permission Set with the Security Filter applied will see restricted data.

Note: The code and information discussed in this article is for informational and demonstration purposes only. This content was created referencing Microsoft Dynamics 365 Business Central 2022 Wave 1

It’s Friday – August 19

Dynamics 365 Business Central: AllowScheduling Property

One great feature of Microsoft Dynamics 365 Business Central is the option to schedule Reports. As beneficial as this feature may be, there may be cases where the opportunity to schedule a report is not desired. Fortunately, there is a way for a report developer to control this option.

The ability to schedule a report is handled through the AllowScheduling Property of the report definition. When creating a report, a developer can determine if the report can be scheduled in the background and executed by the Job Scheduler using the AllowScheduling property. 

Setting the AllowScheduling Property to true shows the Schedule option on the report dialog that appears after the “Send To…” button is clicked.

Setting the AllowScheduling Property to false hides the Schedule option on the report dialog that appears after the “Send To…” button is clicked.

In Microsoft Dynamics 365 Business Central, the default behavior of the AllowScheduling property is true. The AllowScheduling Property cannot be changed on Report Extensions.

Click to read additional information on the AllowScheduling Property.

Note: The code and information discussed in this article is for informational and demonstration purposes only. This content was created referencing Microsoft Dynamics 365 Business Central 2022 Wave 1

Dynamics 365 Business Central: Schedule Reports

One feature of Microsoft Dynamics 365 Business Central is the scheduling of Reports. Schedule Reports are saved to a file or printed to a specific printer. Similar to other scheduled tasks, scheduled reports are processed through the job queue and scheduled to execute once or on a recurring interval. Scheduling reports is an excellent way to offload tasks from the users and minimize any impacts of executing the report while users are active in the application.

Schedule a report with the Schedule option, found on the options page, after clicking the “Send To…” button on the Report’s Request Page. When scheduling a report, the Report’s Request Page options entered are applied when the scheduled report job executes.

If you save the report to a file, it will appear in the Report Inbox, where it can be viewed or saved in another location. A printed report will print to the selected printer. A report scheduled to run once will be removed from the job queue after execution, whereas recurring jobs will move to the next scheduled interval.

  1. Enter the desired options on the Report’s Request Page and click the “Send To…” button
  2. Select the Schedule option and click Ok to open the scheduling options dialog
  3. Enter the report scheduling options.
    – Select the Report Output Type; If the report output is printed enter the Printer Name, if the output type is a file, it will appear in the Report Inbox
    – If the report is a recurring report, enter the date formula to use for calculating the Report’s next Start Date/Time. 
    – Select when the Earliest Date/Time the report will execute, and if the report is a recurring report you can optionally add an Expiration Date/Time.
  4. Once scheduled, a Job Queue Entry is created. If changes are needed to the report or schedule, they are done on the Job Queue Entry. The Report Options are accessible with the “Report Request Page” action and the output adjusted in the Report Parameters Fast Tab. The standard Job Queue options control the report execution schedule.
  5. Reports that are output to a file appear in the Report Inbox. Search for “Report In Box” using the “Tell Me” action in the App Bar and click the “Report Inbox” Lists link  

I will discuss how a developer can control the Schedule option of a report in a future post.

Note: The code and information discussed in this article is for informational and demonstration purposes only. This content was created referencing Microsoft Dynamics 365 Business Central 2022 Wave 1

Dynamics 365 Business Central: Monitor Field Changes

The Change Log has long been part of Microsoft Dynamics 365 Business Central and is used (misused and abused) to track field value changes. The Change Log allows a System Administrator to define which Tables and Fields to monitor for Insert, Modify and Delete events. Once activated, field value changes are visible on the Change Log Entries page.

Before I continue (did I mention how many times I have seen this abused?), it is essential to note that using Change Log or Field Monitor may impact performance and needs to be considered when determining the Table and fields to monitor.

Things changed a bit with the release of 2020 Wave 2 and the addition of the Monitored Field Worksheet. In addition to field change logging, the Monitored Field Worksheet feature added notifications. You can set up notifications when values change on what you may consider sensitive or essential data.

  1. Enable Field Monitoring Setup:
    1. Search for “Field Monitoring Setup” using the “Tell Me” action in the App Bar and click the “Field Monitoring Setup” Administration link
    2. Select the Notification Recipient
    3. Select the Notification E-mail Account (E-mail set up is a prerequisite)
    4. Click Start in the Action Ribbon; To disable monitoring click the Stop Action.
  2. Set up field change notifications
    1. Search for “Monitored Field Worksheet” using the “Tell Me” action in the App Bar and click the “Monitored Field Worksheet” Administration link.
    2. The “Monitored Fields Worksheet” opens, and in the Worksheet, add the Table and Field combinations to monitor.
      1. Enter the Table number to monitor; this can be entered directly or selected from the Table list that is accessible by clicking the “three dots” adjacent to the field.
      2. Enter the Field number to monitor; this can be entered directly or selected from the Field list accessible by clicking the “three dots” adjacent to the field.
    3. Enable the fields to Notify by selecting the rows and selecting the “Set for Notification” action; the “Clear for Notification” action will disable the fields to Notify.

Note: The code and information discussed in this article is for informational and demonstration purposes only. This content was created referencing Microsoft Dynamics 365 Business Central 2022 Wave 1

It’s Friday – August 12

Dynamics 365 Business Central: General Ledger Entry Dimension Corrections

Dimensions in Microsoft Dynamics 365 Business Central have many uses; however, their primary use is for financial reports and analysis. There are many ways to set up and enforce Dimension Value posting within Microsoft Dynamics 365 Business Central. Yet, in an implementation with proper dimensions setup, a need to correct the dimensions on posted general ledger entries may occur.

 Before the 2021 Wave 1 release of Business Central, you would have to work with an application developer to develop a utility to adjust the dimension values  or post correcting entries to correct the General Ledger Entry dimension. Starting back with the 2021 release, Dimension Corrections (on General Ledger Entries) is possible.

 To correct the dimension values for a GL Entry:

  1. Select the General Ledger Entry/ies that need to have dimension values updated on the General Ledger Entries page
  2. Select Entry -> Correct Dimensions from the Action Ribbon.
  3. On the Draft Dimension Entry page, enter a practical description of about the change. This description may be helpful in the future. 
  4. In the Dimension Correction Change lines, change the dimension values to the desired value or remove the dimension if it is unnecessary.
  5. Review the Selected Ledger Entries fast tab to confirm the selected entries affected by the change
  6. Select Run to execute the change Note: The change may be run immediately or scheduled to run during a time that may be less impactful to other users.
  7. To see the history of the Dimension Value changes on a General Ledger Entry, select Entry ->History of Dimension Corrections from the Action Ribbon. 

Note: Correcting dimensions on General Ledger Entries is intended to help with financial reporting only. Dimension corrections are on the General Ledger Entries only; any related transactions are not updated and retain the original posting dimension values.

Note: The code and information discussed in this article is for informational and demonstration purposes only. This content was created referencing Microsoft Dynamics 365 Business Central 2022 Wave 1

It’s Friday! – August 5