Posts

Showing posts with the label PowerShell

How to use D365 BC 2022 AdminTool from Windows PowerShel

Image
The new edition of "Dynamics 365 Business Central 2022" does not include a graphical interface for the admin tool. The command-line admin tool is not very user-friendly. A better alternative is to use "Windows PowerShell ISE". It has some features that make it easier to write commands for the admin tool. Here is how to use it: Write the following script in PowerShell and run it. It will open the admin tool in PowerShell.  Then you can choose different commands from the admin tool in the command window to write any script. Import-Module 'C:\Program Files\Microsoft Dynamics 365 Business Central\210\Service\NavAdminTool.ps1' If error execute: Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted ·          To get all server configuration: Get-NAVServerConfiguration -ServerInstance BC210 ·          To set server configuration: Set-NAVServerConfiguration -KeyName DeveloperService...

How to send Email using command in Windows

Image
You can not use Command Prompt directly to send an email, but using PowerShell allows you to use the underlying .Net Framework, you can easily create and send an  e-mail from the command line.  #this works, just sends a simple email $smtpServer = "your.webmailserver.com" $smtpFrom = "fromadress@webmailserver.com" $smtpTo = "todaddress@webmailserver.com" $smtpCc = 'ccdaddress@webmailserver.com' $smtpSubject = "This is a test email" $username = "username" $password = "password" $body = "your mail body goes here" $smtp = New-Object -TypeName "Net.Mail.SmtpClient" -ArgumentList $smtpServer $smtp.Credentials = New-Object system.net.networkcredential($username, $Password); $smtpBody = $body $SMTPMessage = New-Object System.Net.Mail.MailMessage($smtpFrom, $smtpTo, $smtpSubject, $smtpBody) $SMTPMessage.cc.Add($smtpCc) $SMTPMessage.IsBodyHTML=$true $smtp.Send($SMTPMessage) You can run this sc...